pub struct ExponentialBackoff<C> {
pub current_interval: Duration,
pub initial_interval: Duration,
pub randomization_factor: f64,
pub multiplier: f64,
pub max_interval: Duration,
pub start_time: Instant,
pub max_elapsed_time: Option<Duration>,
pub clock: C,
}Fields§
§current_interval: DurationThe current retry interval.
initial_interval: DurationThe initial retry interval.
randomization_factor: f64The randomization factor to use for creating a range around the retry interval.
A randomization factor of 0.5 results in a random period ranging between 50% below and 50% above the retry interval.
multiplier: f64The value to multiply the current interval with for each retry attempt.
max_interval: DurationThe maximum value of the back off period. Once the retry interval reaches this value it stops increasing.
start_time: InstantThe system time. It is calculated when an ExponentialBackoff instance is
created and is reset when retry is called.
max_elapsed_time: Option<Duration>The maximum elapsed time after instantiating ExponentialBackfff or calling
reset after which next_backoff returns None.
clock: CThe clock used to get the current time.
Implementations§
source§impl<C> ExponentialBackoff<C>where
C: Clock,
impl<C> ExponentialBackoff<C>where
C: Clock,
sourcepub fn get_elapsed_time(&self) -> Duration
pub fn get_elapsed_time(&self) -> Duration
Returns the elapsed time since start_time.
Trait Implementations§
source§impl<C> Backoff for ExponentialBackoff<C>where
C: Clock,
impl<C> Backoff for ExponentialBackoff<C>where
C: Clock,
source§impl<C> Clone for ExponentialBackoff<C>where
C: Clone,
impl<C> Clone for ExponentialBackoff<C>where
C: Clone,
source§fn clone(&self) -> ExponentialBackoff<C>
fn clone(&self) -> ExponentialBackoff<C>
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<C> Debug for ExponentialBackoff<C>where
C: Debug,
impl<C> Debug for ExponentialBackoff<C>where
C: Debug,
Auto Trait Implementations§
impl<C> Freeze for ExponentialBackoff<C>where
C: Freeze,
impl<C> RefUnwindSafe for ExponentialBackoff<C>where
C: RefUnwindSafe,
impl<C> Send for ExponentialBackoff<C>where
C: Send,
impl<C> Sync for ExponentialBackoff<C>where
C: Sync,
impl<C> Unpin for ExponentialBackoff<C>where
C: Unpin,
impl<C> UnwindSafe for ExponentialBackoff<C>where
C: UnwindSafe,
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