pub struct PeerAdaptiveTimeout {
pub estimates: HashMap<String, TimeoutEstimate>,
pub config: AdaptiveTimeoutConfig,
pub total_samples: u64,
}Expand description
Per-peer adaptive timeout manager.
Maintains a TimeoutEstimate for every peer that has provided at least one RTT sample and
exposes methods to query the recommended timeout or remove stale peers.
Fields§
§estimates: HashMap<String, TimeoutEstimate>Map from peer_id to its current timeout estimate.
config: AdaptiveTimeoutConfigAlgorithm configuration.
total_samples: u64Total RTT samples recorded across all peers (monotonically increasing).
Implementations§
Source§impl PeerAdaptiveTimeout
impl PeerAdaptiveTimeout
Sourcepub fn new(config: AdaptiveTimeoutConfig) -> Self
pub fn new(config: AdaptiveTimeoutConfig) -> Self
Create a new PeerAdaptiveTimeout with the given configuration.
Sourcepub fn record_sample(&mut self, sample: RttSample)
pub fn record_sample(&mut self, sample: RttSample)
Sourcepub fn timeout_for(&self, peer_id: &str) -> Option<u64>
pub fn timeout_for(&self, peer_id: &str) -> Option<u64>
Returns the recommended timeout for peer_id if it has been tracked, or None otherwise.
Sourcepub fn timeout_or_default(&self, peer_id: &str) -> u64
pub fn timeout_or_default(&self, peer_id: &str) -> u64
Returns the recommended timeout for peer_id, falling back to max_timeout_micros for
unknown peers (conservative default).
Sourcepub fn remove_peer(&mut self, peer_id: &str) -> bool
pub fn remove_peer(&mut self, peer_id: &str) -> bool
Remove all state for peer_id.
Returns true if the peer was tracked and has been removed, false if it was unknown.
Sourcepub fn stats(&self) -> TimeoutStats
pub fn stats(&self) -> TimeoutStats
Compute aggregate statistics over all currently tracked peers.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PeerAdaptiveTimeout
impl RefUnwindSafe for PeerAdaptiveTimeout
impl Send for PeerAdaptiveTimeout
impl Sync for PeerAdaptiveTimeout
impl Unpin for PeerAdaptiveTimeout
impl UnsafeUnpin for PeerAdaptiveTimeout
impl UnwindSafe for PeerAdaptiveTimeout
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more