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
impl RetryPolicy
Sourcepub fn exponential(delay: Duration) -> Self
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
Sourcepub fn fixed(delay: Duration) -> Self
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
Sourcepub fn with_jitter(self, jitter: bool) -> Self
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
Sourcepub fn with_max_delay(self, max: Duration) -> Self
pub fn with_max_delay(self, max: Duration) -> Self
Limits the maximum length of delay between retries
Sourcepub fn with_max_retries(self, max: usize) -> Self
pub fn with_max_retries(self, max: usize) -> Self
Limits the maximum number of attempts a Future will be tried
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§fn clone(&self) -> RetryPolicy
fn clone(&self) -> RetryPolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more