Struct PeakEwma
pub struct PeakEwma<S, C = CompleteOnResponse> { /* private fields */ }
Measures the load of the underlying service using Peak-EWMA load measurement.
PeakEwma implements Load with the Cost metric that estimates the amount of
pending work to an endpoint. Work is calculated by multiplying the
exponentially-weighted moving average (EWMA) of response latencies by the number of
pending requests. The Peak-EWMA algorithm is designed to be especially sensitive to
worst-case latencies. Over time, the peak latency value decays towards the moving
average of latencies to the endpoint.
When no latency information has been measured for an endpoint, an arbitrary default RTT of 1 second is used to prevent the endpoint from being overloaded before a meaningful baseline can be established..
Note
This is derived from Finagle, which is distributed under the Apache V2 license. Copyright 2017, Twitter Inc.
Implementations
impl<S, C> PeakEwma<S, C>
fn new(service: S, default_rtt: Duration, decay_ns: f64, completion: C) -> SelfWraps an
S-typed service so that its load is tracked by the EWMA of its peak latency.
Trait Implementations
impl<S, C> Load for PeakEwma<S, C>
type Metric = Cost;fn load(&self) -> Self::Metric
impl<S, C, Request> Service<Request> for PeakEwma<S, C>
where
S: Service<Request>,
C: TrackCompletion<Handle, S::Response>,
type Response = <C as TrackCompletion<Handle, <S as Service<Request>>::Response>>::Output;type Error = <S as Service<Request>>::Error;type Future = TrackCompletionFuture<<S as Service<Request>>::Future, C, Handle>;fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>fn call(&mut self, req: Request) -> Self::Future
impl<S: Debug, C: Debug> Debug for PeakEwma<S, C>
fn fmt(&self, f: &mut Formatter<'_>) -> Result