#[non_exhaustive]pub struct ExponentialBackoff {
pub max_n_retries: Option<u32>,
pub min_retry_interval: Duration,
pub max_retry_interval: Duration,
pub jitter: Jitter,
pub base: u32,
}
Expand description
Exponential backoff with optional jitter.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.max_n_retries: Option<u32>
Maximum number of allowed retries attempts.
min_retry_interval: Duration
Minimum waiting time between two retry attempts (it can end up being lower when using full jitter).
max_retry_interval: Duration
Maximum waiting time between two retry attempts.
jitter: Jitter
How we apply jitter to the calculated backoff intervals.
base: u32
Base of the exponential
Implementations§
Source§impl ExponentialBackoff
impl ExponentialBackoff
Sourcepub fn builder() -> ExponentialBackoffBuilder
pub fn builder() -> ExponentialBackoffBuilder
Returns a builder.
§Example
use retry_policies::policies::ExponentialBackoff;
use std::time::Duration;
let backoff = ExponentialBackoff::builder()
.build_with_max_retries(5);
assert_eq!(backoff.min_retry_interval, Duration::from_secs(1));
assert_eq!(backoff.max_retry_interval, Duration::from_secs(30 * 60));
assert_eq!(backoff.max_n_retries, Some(5));
assert_eq!(backoff.base, 2);
Trait Implementations§
Source§impl Clone for ExponentialBackoff
impl Clone for ExponentialBackoff
Source§fn clone(&self) -> ExponentialBackoff
fn clone(&self) -> ExponentialBackoff
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 ExponentialBackoff
impl Debug for ExponentialBackoff
Source§impl PartialEq for ExponentialBackoff
impl PartialEq for ExponentialBackoff
Source§impl RetryPolicy for ExponentialBackoff
impl RetryPolicy for ExponentialBackoff
Source§fn should_retry(
&self,
_request_start_time: SystemTime,
n_past_retries: u32,
) -> RetryDecision
fn should_retry( &self, _request_start_time: SystemTime, n_past_retries: u32, ) -> RetryDecision
Determine if a task should be retried according to a retry policy.
impl Copy for ExponentialBackoff
impl Eq for ExponentialBackoff
impl StructuralPartialEq for ExponentialBackoff
Auto Trait Implementations§
impl Freeze for ExponentialBackoff
impl RefUnwindSafe for ExponentialBackoff
impl Send for ExponentialBackoff
impl Sync for ExponentialBackoff
impl Unpin for ExponentialBackoff
impl UnwindSafe for ExponentialBackoff
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.