Crate tokio_timeit_middleware [−] [src]
tokio-timeit-middleware
provides a middleware Tokio Service
called
Timeit
to time how long it takes to reply to a
Service::Request
with a Service::Response
.
The recorded timings are sent to a TimeSink
which may be any smart pointer
type that Deref
s to a function that takes a
time::Duration
and is Clone
.
Example
// Send recorded timings to metrics or logging or whatever... let time_sink = Rc::new(|timing: time::Duration| { println!("Replied to a request with a response in {}", timing); }); // Wrap a service in `Timeit`! let my_timed_service = tokio_timeit_middleware::Timeit::new(my_tokio_service, time_sink);
Structs
Timeit |
A middleware that times how long it takes the downstream service |