pub struct RetryBackoff { /* private fields */ }Expand description
A retry ladder: a delay that doubles from a minimum up to a maximum with
each failure, until Self::reset.
Plain, it waits exactly that delay, for ladders whose sequence is a
contract. Self::with_jitter spreads it, for retries against a shared
server.
Implementations§
Source§impl RetryBackoff
impl RetryBackoff
Sourcepub const MAX_DOUBLINGS: u32 = 10
pub const MAX_DOUBLINGS: u32 = 10
How many times the delay doubles before it stops growing: past that it
stays at the minimum times 2^MAX_DOUBLINGS (1024), or the maximum if
that is lower.
pub fn new(min_delay: Duration, max_delay: Duration) -> Self
Sourcepub fn with_jitter(self) -> Self
pub fn with_jitter(self) -> Self
This ladder, each delay drawn at random from its last quarter: from three quarters of the plain delay up to the plain delay itself.
For retries that many processes make against one server, such as clients of a relay that restarted: they failed together and would otherwise come back together, at every step. A delay is never longer than the plain one, so the cap holds and no retry comes later.
pub fn failures(&self) -> u32
pub fn reset(&mut self)
pub fn next_delay(&mut self) -> Duration
Trait Implementations§
Source§impl Clone for RetryBackoff
impl Clone for RetryBackoff
impl Copy for RetryBackoff
Source§impl Debug for RetryBackoff
impl Debug for RetryBackoff
Auto Trait Implementations§
impl Forget for RetryBackoff
impl Freeze for RetryBackoff
impl Move for RetryBackoff
impl RefUnwindSafe for RetryBackoff
impl Send for RetryBackoff
impl Sync for RetryBackoff
impl Unpin for RetryBackoff
impl UnsafeUnpin for RetryBackoff
impl UnwindSafe for RetryBackoff
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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