Struct retry_policies::policies::ExponentialBackoff

source ·
#[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

source

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

source§

fn clone(&self) -> ExponentialBackoff

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ExponentialBackoff

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for ExponentialBackoff

source§

fn eq(&self, other: &ExponentialBackoff) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl RetryPolicy for ExponentialBackoff

source§

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.
source§

impl Copy for ExponentialBackoff

source§

impl Eq for ExponentialBackoff

source§

impl StructuralPartialEq for ExponentialBackoff

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V