pub struct Backoff { /* private fields */ }Expand description
Exponential backoff starting at 500ms and capping at 30 seconds.
Each call to next_delay doubles the delay
(with jitter) up to the configured maximum. Call reset
after a successful connection to start over.
Implementations§
Source§impl Backoff
impl Backoff
Sourcepub fn next_delay(&mut self) -> Duration
pub fn next_delay(&mut self) -> Duration
Get the next backoff duration and advance the state.
The delay is base_ms * 2^attempt, clamped to max_ms, with a
small deterministic jitter derived from the attempt number.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset the backoff to the initial value (call on successful connection).
Sourcepub fn current_ms(&self) -> u64
pub fn current_ms(&self) -> u64
Get the current backoff duration in milliseconds (without advancing).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Backoff
impl RefUnwindSafe for Backoff
impl Send for Backoff
impl Sync for Backoff
impl Unpin for Backoff
impl UnsafeUnpin for Backoff
impl UnwindSafe for Backoff
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