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
Auto Trait Implementations
impl<S, C> Freeze for PeakEwma<S, C>
where
S: Freeze,
C: Freeze,
impl<S, C> RefUnwindSafe for PeakEwma<S, C>
where
S: RefUnwindSafe,
C: RefUnwindSafe,
impl<S, C> Send for PeakEwma<S, C>
where
S: Send,
C: Send,
impl<S, C> Sync for PeakEwma<S, C>
where
S: Sync,
C: Sync,
impl<S, C> Unpin for PeakEwma<S, C>
where
S: Unpin,
C: Unpin,
impl<S, C> UnsafeUnpin for PeakEwma<S, C>
where
S: UnsafeUnpin,
C: UnsafeUnpin,
impl<S, C> UnwindSafe for PeakEwma<S, C>
where
S: UnwindSafe,
C: UnwindSafe,
Blanket Implementations
impl<C, Target> MakeConnection<Target> for PeakEwma<S, C>
where
C: Service<Target>,
<C as Service<Target>>::Response: AsyncRead + AsyncWrite,
type Connection = <C as Service<Target>>::Response;type Error = <C as Service<Target>>::Error;type Future = <C as Service<Target>>::Future;fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), <C as MakeConnection<Target>>::Error>>fn make_connection(&mut self, target: Target) -> <C as MakeConnection<Target>>::Future
impl<M, S, Target, Request> MakeService<Target, Request> for PeakEwma<S, C>
where
M: Service<Target, Response = S>,
S: Service<Request>,
type Response = <S as Service<Request>>::Response;type Error = <S as Service<Request>>::Error;type Service = S;type MakeError = <M as Service<Target>>::Error;type Future = <M as Service<Target>>::Future;fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), <M as MakeService<Target, Request>>::MakeError>>fn make_service(&mut self, target: Target) -> <M as MakeService<Target, Request>>::Future
impl<T> Any for PeakEwma<S, C>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for PeakEwma<S, C>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for PeakEwma<S, C>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for PeakEwma<S, C>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Instrument for PeakEwma<S, C>
impl<T> WithSubscriber for PeakEwma<S, C>
impl<T, Request> ServiceExt<Request> for PeakEwma<S, C>
where
T: Service<Request> + ?Sized,
impl<T, U> Into<U> for PeakEwma<S, C>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for PeakEwma<S, C>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for PeakEwma<S, C>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>