pub struct BackoffManager {
entries: HashMap<PeerId, BackoffEntry>,
}Expand description
Manages backoff states for multiple peers or operations.
Fields§
§entries: HashMap<PeerId, BackoffEntry>Implementations§
Source§impl BackoffManager
impl BackoffManager
Sourcepub fn can_attempt(&self, peer_id: &PeerId) -> bool
pub fn can_attempt(&self, peer_id: &PeerId) -> bool
Checks if an attempt can be made for a given peer.
Sourcepub fn time_until_retry(&self, peer_id: &PeerId) -> Option<Duration>
pub fn time_until_retry(&self, peer_id: &PeerId) -> Option<Duration>
Returns the time remaining until a retry attempt is allowed for a given peer.
Sourcepub fn record_attempt(&mut self, peer_id: PeerId)
pub fn record_attempt(&mut self, peer_id: PeerId)
Records an attempt for a given peer, updating its backoff state.
Sourcepub fn record_success(&mut self, peer_id: &PeerId)
pub fn record_success(&mut self, peer_id: &PeerId)
Records a success for a given peer, resetting its backoff state.
Sourcepub fn record_failure(&mut self, peer_id: PeerId)
pub fn record_failure(&mut self, peer_id: PeerId)
Records a failure for a given peer, updating its backoff state.
Currently, this behaves the same as record_attempt.
Sourcepub fn cleanup_old_entries(&mut self, max_age: Duration)
pub fn cleanup_old_entries(&mut self, max_age: Duration)
Cleans up old backoff entries that have not been updated recently.
Trait Implementations§
Source§impl Debug for BackoffManager
impl Debug for BackoffManager
Auto Trait Implementations§
impl Freeze for BackoffManager
impl RefUnwindSafe for BackoffManager
impl Send for BackoffManager
impl Sync for BackoffManager
impl Unpin for BackoffManager
impl UnwindSafe for BackoffManager
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
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>
Converts
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>
Converts
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