pub struct AdaptiveTimeout { /* private fields */ }Expand description
Adaptive timeout calculator backed by a circular buffer of recent durations.
§Panics
This type never panics.
Implementations§
Source§impl AdaptiveTimeout
impl AdaptiveTimeout
Sourcepub fn new(min_timeout: Duration) -> Self
pub fn new(min_timeout: Duration) -> Self
Creates a new AdaptiveTimeout with the given minimum timeout floor.
§Arguments
min_timeout— Minimum timeout value. The computedp95 * 2.0will never go below this value.
Sourcepub fn record_duration(&mut self, duration: Duration)
pub fn record_duration(&mut self, duration: Duration)
Records a completed request duration into the rolling buffer.
Once the buffer is full the oldest sample is overwritten (circular).
§Panics
This function does not panic.
Sourcepub fn current_timeout(&self) -> Duration
pub fn current_timeout(&self) -> Duration
Returns the current adaptive timeout.
With fewer than 2 samples the configured min_timeout is returned.
Otherwise: max(min_timeout, p95 * 2.0).
§Panics
This function does not panic.
Sourcepub fn sample_count(&self) -> usize
pub fn sample_count(&self) -> usize
Trait Implementations§
Source§impl Clone for AdaptiveTimeout
impl Clone for AdaptiveTimeout
Source§fn clone(&self) -> AdaptiveTimeout
fn clone(&self) -> AdaptiveTimeout
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AdaptiveTimeout
impl RefUnwindSafe for AdaptiveTimeout
impl Send for AdaptiveTimeout
impl Sync for AdaptiveTimeout
impl Unpin for AdaptiveTimeout
impl UnsafeUnpin for AdaptiveTimeout
impl UnwindSafe for AdaptiveTimeout
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§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<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request