Struct RetryPolicy

Source
pub struct RetryPolicy { /* private fields */ }
Expand description

A template for configuring retry behavior

A default is provided, configured to retry a task 5 times with exponential backoff starting with a 1 second delay

Implementations§

Source§

impl RetryPolicy

Source

pub fn exponential(delay: Duration) -> Self

Configures policy with an exponential backoff delay.

By default, Futures will be retried 5 times.

These delays will increase in length over time. You may wish to cap just how long using the with_max_delay fn

Source

pub fn fixed(delay: Duration) -> Self

Configures policy with a fixed backoff delay.

By default, Futures will be retried 5 times.

These delays will increase in length over time. You may wish to configure how many times a Future will be retried using the with_max_retries fn

Source

pub fn with_jitter(self, jitter: bool) -> Self

Configures randomness to the delay between retries.

This is useful for services that have many clients which might all retry at the same time to avoid the “thundering herd” problem

Source

pub fn with_max_delay(self, max: Duration) -> Self

Limits the maximum length of delay between retries

Source

pub fn with_max_retries(self, max: usize) -> Self

Limits the maximum number of attempts a Future will be tried

Source

pub async fn retry<T>(&self, task: T) -> Result<T::Item, T::Error>
where T: Task,

Retries a fallible Future with this policy’s configuration

Source

pub async fn retry_if<T, C>( &self, task: T, condition: C, ) -> Result<T::Item, T::Error>
where T: Task, C: Condition<T::Error>,

Retries a fallible Future with this policy’s configuration under certain provided conditions

Trait Implementations§

Source§

impl Clone for RetryPolicy

Source§

fn clone(&self) -> RetryPolicy

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 Default for RetryPolicy

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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>,

Source§

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>,

Source§

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