pub struct PeakEwma<S, C = CompleteOnResponse> { /* private fields */ }load only.Expand description
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§
Source§impl<S, C> PeakEwma<S, C>
impl<S, C> PeakEwma<S, C>
Sourcepub fn new(
service: S,
default_rtt: Duration,
decay_ns: f64,
completion: C,
) -> Self
pub fn new( service: S, default_rtt: Duration, decay_ns: f64, completion: C, ) -> Self
Wraps an S-typed service so that its load is tracked by the EWMA of its peak latency.
Sourcepub fn rtt_estimate(&self) -> RttEstimate
pub fn rtt_estimate(&self) -> RttEstimate
Returns the current RttEstimate of the service.
§Panics
This value is stored in a mutex. If the mutex has become poisoned, this will panic.
Trait Implementations§
Source§impl<S, C, Request> Service<Request> for PeakEwma<S, C>
impl<S, C, Request> Service<Request> for PeakEwma<S, C>
Source§type Response = <C as TrackCompletion<Handle, <S as Service<Request>>::Response>>::Output
type Response = <C as TrackCompletion<Handle, <S as Service<Request>>::Response>>::Output
Source§type Future = TrackCompletionFuture<<S as Service<Request>>::Future, C, Handle>
type Future = TrackCompletionFuture<<S as Service<Request>>::Future, C, Handle>
Auto Trait Implementations§
impl<S, C> Freeze for PeakEwma<S, C>
impl<S, C> RefUnwindSafe for PeakEwma<S, C>where
S: RefUnwindSafe,
C: RefUnwindSafe,
impl<S, C> Send for PeakEwma<S, C>
impl<S, C> Sync for PeakEwma<S, C>
impl<S, C> Unpin for PeakEwma<S, C>
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<M, S, Target, Request> MakeService<Target, Request> for M
impl<M, S, Target, Request> MakeService<Target, Request> for M
Source§type Response = <S as Service<Request>>::Response
type Response = <S as Service<Request>>::Response
make only.Source§type Error = <S as Service<Request>>::Error
type Error = <S as Service<Request>>::Error
make only.Source§type Service = S
type Service = S
make only.Service value created by this factorySource§type MakeError = <M as Service<Target>>::Error
type MakeError = <M as Service<Target>>::Error
make only.Source§type Future = <M as Service<Target>>::Future
type Future = <M as Service<Target>>::Future
make only.Service instance.Source§fn poll_ready(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Result<(), <M as MakeService<Target, Request>>::MakeError>>
fn poll_ready( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<(), <M as MakeService<Target, Request>>::MakeError>>
make only.Poll::Ready when the factory is able to create more services. Read moreSource§fn make_service(
&mut self,
target: Target,
) -> <M as MakeService<Target, Request>>::Future
fn make_service( &mut self, target: Target, ) -> <M as MakeService<Target, Request>>::Future
make only.Source§fn into_service(self) -> IntoService<Self, Request>where
Self: Sized,
fn into_service(self) -> IntoService<Self, Request>where
Self: Sized,
make only.Source§fn as_service(&mut self) -> AsService<'_, Self, Request>where
Self: Sized,
fn as_service(&mut self) -> AsService<'_, Self, Request>where
Self: Sized,
make only.Source§impl<T, Request> ServiceExt<Request> for T
impl<T, Request> ServiceExt<Request> for T
Source§fn ready(&mut self) -> Ready<'_, Self, Request> ⓘwhere
Self: Sized,
fn ready(&mut self) -> Ready<'_, Self, Request> ⓘwhere
Self: Sized,
util only.Source§fn ready_oneshot(self) -> ReadyOneshot<Self, Request> ⓘwhere
Self: Sized,
fn ready_oneshot(self) -> ReadyOneshot<Self, Request> ⓘwhere
Self: Sized,
util only.Source§fn oneshot(self, req: Request) -> Oneshot<Self, Request> ⓘwhere
Self: Sized,
fn oneshot(self, req: Request) -> Oneshot<Self, Request> ⓘwhere
Self: Sized,
util only.Service, calling it with the provided request once it is ready.Source§fn call_all<S>(self, reqs: S) -> CallAll<Self, S>where
Self: Sized,
S: Stream<Item = Request>,
fn call_all<S>(self, reqs: S) -> CallAll<Self, S>where
Self: Sized,
S: Stream<Item = Request>,
util only.Source§fn and_then<F>(self, f: F) -> AndThen<Self, F>
fn and_then<F>(self, f: F) -> AndThen<Self, F>
util only.poll_ready method. Read moreSource§fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
util only.poll_ready method. Read moreSource§fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
util only.poll_ready method. Read moreSource§fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
util only.Result<Self::Response, Self::Error>)
to a different value, regardless of whether the future succeeds or
fails. Read moreSource§fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F>
fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F>
util only.Source§fn filter<F, NewRequest>(self, filter: F) -> Filter<Self, F>
fn filter<F, NewRequest>(self, filter: F) -> Filter<Self, F>
filter and util only.Source§fn filter_async<F, NewRequest>(self, filter: F) -> AsyncFilter<Self, F>where
Self: Sized,
F: AsyncPredicate<NewRequest>,
fn filter_async<F, NewRequest>(self, filter: F) -> AsyncFilter<Self, F>where
Self: Sized,
F: AsyncPredicate<NewRequest>,
filter and util only.AsyncFilter that conditionally accepts or
rejects requests based on an [async predicate]. Read moreSource§fn then<F, Response, Error, Fut>(self, f: F) -> Then<Self, F>
fn then<F, Response, Error, Fut>(self, f: F) -> Then<Self, F>
util only.Source§fn map_future<F, Fut, Response, Error>(self, f: F) -> MapFuture<Self, F>
fn map_future<F, Fut, Response, Error>(self, f: F) -> MapFuture<Self, F>
util only.Source§fn buffered(self, bound: usize) -> Buffer<Request, Self::Future>
fn buffered(self, bound: usize) -> Buffer<Request, Self::Future>
buffer and util only.Source§fn retry<P>(self, policy: P) -> Retry<P, Self>where
Self: Sized,
fn retry<P>(self, policy: P) -> Retry<P, Self>where
Self: Sized,
retry and util only.