pub struct ExponentialBackoffRetryPolicy<E> { /* private fields */ }Expand description
The exponential backoff strategy is a retry approach that doubles the delay between retries. A combined exponential backoff and jitter strategy is recommended that is “Exponential Backoff and Jitter”. This is helpful to avoid Thundering Herd Problem.
Implementations§
Source§impl<E: Error> ExponentialBackoffRetryPolicy<E>
impl<E: Error> ExponentialBackoffRetryPolicy<E>
Sourcepub fn new(base_delay: Duration) -> ExponentialBackoffRetryPolicy<E>
pub fn new(base_delay: Duration) -> ExponentialBackoffRetryPolicy<E>
Constructs a new instance using base_delay.
base_delay is the base delay duration for the backoff algorithm. First retry is base_delay
after first attempt.
Trait Implementations§
Source§impl<E: Error> RetryPolicy for ExponentialBackoffRetryPolicy<E>
impl<E: Error> RetryPolicy for ExponentialBackoffRetryPolicy<E>
Source§fn next_delay(&self, context: &RetryContext<'_, Self::E>) -> Option<Duration>
fn next_delay(&self, context: &RetryContext<'_, Self::E>) -> Option<Duration>
Returns the duration to wait before trying the next attempt.
context represents the context of a retry operation. Read moreSource§fn with_max_attempts(self, max_attempts: u32) -> MaxAttemptsRetryPolicy<Self>
fn with_max_attempts(self, max_attempts: u32) -> MaxAttemptsRetryPolicy<Self>
Returns a new
RetryPolicy that respects the given maximum attempts.Source§fn with_max_total_delay(
self,
max_total_delay: Duration,
) -> MaxTotalDelayRetryPolicy<Self>
fn with_max_total_delay( self, max_total_delay: Duration, ) -> MaxTotalDelayRetryPolicy<Self>
Returns a new
RetryPolicy that respects the given total delay.Source§fn with_max_jitter(self, max_jitter: Duration) -> JitteredRetryPolicy<Self>
fn with_max_jitter(self, max_jitter: Duration) -> JitteredRetryPolicy<Self>
Returns a new
RetryPolicy that adds jitter(random delay) to underlying policy.Source§fn skip_retry_on_error<F>(self, function: F) -> FilteredRetryPolicy<Self, F>
fn skip_retry_on_error<F>(self, function: F) -> FilteredRetryPolicy<Self, F>
Skips retrying on errors that evaluate to
true after applying function.Auto Trait Implementations§
impl<E> Freeze for ExponentialBackoffRetryPolicy<E>
impl<E> RefUnwindSafe for ExponentialBackoffRetryPolicy<E>where
E: RefUnwindSafe,
impl<E> Send for ExponentialBackoffRetryPolicy<E>where
E: Send,
impl<E> Sync for ExponentialBackoffRetryPolicy<E>where
E: Sync,
impl<E> Unpin for ExponentialBackoffRetryPolicy<E>where
E: Unpin,
impl<E> UnwindSafe for ExponentialBackoffRetryPolicy<E>where
E: 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