pub struct RetryDelay { /* private fields */ }
Expand description
An implementation for retrying a remote operation based on a decorrelated jitter schedule.
The algorithm used here has several desirable properties:
- It is randomized, so that multiple timeouts don’t have a danger of getting synchronized with each other and hammering the same servers all at once.
- It tends on average to wait longer and longer over time, so that if the server is down, it won’t get pummeled by a zillion failing clients when it comes back up.
- It has a chance of retrying promptly, which results in better client performance on average.
For a more full specification, see dir-spec.txt
.
Implementations§
Source§impl RetryDelay
impl RetryDelay
Sourcepub fn from_msec(base_delay_msec: u32) -> Self
pub fn from_msec(base_delay_msec: u32) -> Self
Construct a new RetryDelay from a given base delay in milliseconds.
The base delay defines the lowest possible interval that can be returned.
§Limitations
If the base delay is less than 1000, a base delay of 1000 is used instead, since that’s what the C tor implementation does.
Sourcepub fn from_duration(d: Duration) -> Self
pub fn from_duration(d: Duration) -> Self
Construct a new RetryDelay from a given base delay.
See from_msec for more information.
Sourcepub fn next_delay<R: Rng>(&mut self, rng: &mut R) -> Duration
pub fn next_delay<R: Rng>(&mut self, rng: &mut R) -> Duration
Return the next delay to be used (as a Duration
),
according to a given random number generator.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Return this RetryDelay
to its original state.
Trait Implementations§
Source§impl Clone for RetryDelay
impl Clone for RetryDelay
Source§fn clone(&self) -> RetryDelay
fn clone(&self) -> RetryDelay
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for RetryDelay
impl Debug for RetryDelay
Auto Trait Implementations§
impl Freeze for RetryDelay
impl RefUnwindSafe for RetryDelay
impl Send for RetryDelay
impl Sync for RetryDelay
impl Unpin for RetryDelay
impl UnwindSafe for RetryDelay
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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