Struct reqwest_retry::policies::ExponentialBackoff
source · [−]pub struct ExponentialBackoff {
pub max_n_retries: u32,
pub min_retry_interval: Duration,
pub max_retry_interval: Duration,
pub backoff_exponent: u32,
}
Expand description
We are using the “decorrelated jitter” approach detailed here:
<https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/>
Fields
max_n_retries: u32
Maximum number of allowed retries attempts.
min_retry_interval: Duration
Minimum waiting time between two retry attempts (it can end up being lower due to jittering).
max_retry_interval: Duration
Maximum waiting time between two retry attempts.
backoff_exponent: u32
Growing factor governing how fast the retry interval increases with respect to the number of failed attempts. If set to 3:
- first retry: 3^0 = 1
- second retry: 3^1 = 3
- third retry: 3^2 = 9 …
Implementations
sourceimpl 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_total_retry_duration(Duration::from_secs(24 * 60 * 60));
assert_eq!(backoff.backoff_exponent, 3);
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, 55); // calculated
Trait Implementations
sourceimpl Clone for ExponentialBackoff
impl Clone for ExponentialBackoff
sourcefn clone(&self) -> ExponentialBackoff
fn clone(&self) -> ExponentialBackoff
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for ExponentialBackoff
impl Debug for ExponentialBackoff
sourceimpl PartialEq<ExponentialBackoff> for ExponentialBackoff
impl PartialEq<ExponentialBackoff> for ExponentialBackoff
sourcefn eq(&self, other: &ExponentialBackoff) -> bool
fn eq(&self, other: &ExponentialBackoff) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &ExponentialBackoff) -> bool
fn ne(&self, other: &ExponentialBackoff) -> bool
This method tests for !=
.
sourceimpl RetryPolicy for ExponentialBackoff
impl RetryPolicy for ExponentialBackoff
sourcefn should_retry(&self, n_past_retries: u32) -> RetryDecision
fn should_retry(&self, 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 StructuralEq for ExponentialBackoff
impl StructuralPartialEq for ExponentialBackoff
Auto Trait Implementations
impl RefUnwindSafe for ExponentialBackoff
impl Send for ExponentialBackoff
impl Sync for ExponentialBackoff
impl Unpin for ExponentialBackoff
impl UnwindSafe for ExponentialBackoff
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more