An open API service indexing awesome lists of open source software.

https://github.com/fitzgen/tokio-timeit-middleware


https://github.com/fitzgen/tokio-timeit-middleware

Last synced: over 1 year ago
JSON representation

Awesome Lists containing this project

README

          

# tokio-timeit-middleware

tokio-timeit-middleware’s current version badge

Time how long it takes your Tokio `Service` to send a `Service::Response` in
reply to a `Service::Request`.

## Usage

First, add this to your Cargo.toml:

```toml
[dependencies]
tokio-timeit-middleware = { git = "https://github.com/fitzgen/tokio-timeit-middleware" }
```

Next, add this to your crate:

```rust
extern crate tokio_timeit_middleware;
```

To time your Tokio `Service`'s request/response times, wrap it in
`tokio_timeit_middleware::Timeit`:

```rust
let timed_service = Timeit::new(my_tokio_service, Rc::new(|duration| {
println!("Responded to request in {}", duration);
));
```