Crate mysql_slowlog_parser

Source
Expand description

§parse-mysql-slowlog streams a slow query and returns a stream of entries from slow logs

from your FramedReader tokio input of choice.

§Example:

 use futures::StreamExt;
 use mysql_slowlog_parser::{CodecError, Entry, EntryCodec};
 use std::ops::AddAssign;
 use std::time::Instant;
 use tokio::fs::File;
 use tokio_util::codec::FramedRead;

 #[tokio::main]
 async fn main() {
 let start = Instant::now();

 let fr = FramedRead::with_capacity(
     File::open("assets/slow-test-queries.log")
     .await
     .unwrap(),
     EntryCodec::default(),
        400000,
);

    let mut i = 0;

    let future = fr.for_each(|re: Result<Entry, CodecError>| async move {
        let _ = re.unwrap();

        i.add_assign(1);
    });

    future.await;
    println!("parsed {} entries in: {}", i, start.elapsed().as_secs_f64());
}

Structs§

  • Struct to pass along configuration values to codec
  • a struct representing a single log entry
  • admin command values parsed from sql lines of an entry
  • struct containing details of how long the query took
  • struct holding contextual information used while decoding
  • Values parsed from a query comment, these values are currently overly-specific
  • struct containing information about the connection where the query originated
  • struct with information about the Entry’s SQL query
  • Database objects called from within a query
  • struct with stats on how long a query took and number of rows examined
  • values from the User: entry line ex. # User@Host: msandbox[msandbox] @ localhost [] Id: 3
  • Struct containing information parsed from the initial comment in a SQL query
  • values parsed from stats entry line
  • A struct holding a DateTime parsed from the Time: line of the entry ex: # Time: 2018-02-05T02:46:43.015898Z

Enums§