Struct reqwest_retry::policies::ExponentialBackoffBuilder
source · [−]pub struct ExponentialBackoffBuilder { /* private fields */ }
Implementations
sourceimpl ExponentialBackoffBuilder
impl ExponentialBackoffBuilder
sourcepub fn retry_bounds(
self,
min_retry_interval: Duration,
max_retry_interval: Duration
) -> ExponentialBackoffBuilder
pub fn retry_bounds(
self,
min_retry_interval: Duration,
max_retry_interval: Duration
) -> ExponentialBackoffBuilder
Add min & max retry interval bounds. Default [1s, 30m].
See ExponentialBackoff::min_retry_interval
, ExponentialBackoff::max_retry_interval
.
Panics if min_retry_interval
> max_retry_interval
.
sourcepub fn backoff_exponent(self, exponent: u32) -> ExponentialBackoffBuilder
pub fn backoff_exponent(self, exponent: u32) -> ExponentialBackoffBuilder
Set backoff exponent. Default 3.
sourcepub fn build_with_max_retries(self, n: u32) -> ExponentialBackoff
pub fn build_with_max_retries(self, n: u32) -> ExponentialBackoff
Builds a ExponentialBackoff
with the given maximum retries.
sourcepub fn build_with_total_retry_duration(
self,
total_duration: Duration
) -> ExponentialBackoff
pub fn build_with_total_retry_duration(
self,
total_duration: Duration
) -> ExponentialBackoff
Builds a ExponentialBackoff
with ExponentialBackoff::max_n_retries
calculated
from an approximate total duration. So that after the resultant max_n_retries
we’ll
have (generally) retried past the given total_duration
.
The actual duration will be approximate due to retry jitter, though this calculation is itself deterministic (based off mean jitter).
Example
use retry_policies::policies::ExponentialBackoff;
use std::time::Duration;
let backoff = ExponentialBackoff::builder()
.backoff_exponent(2)
.retry_bounds(Duration::from_secs(1), Duration::from_secs(60 * 60))
// set a retry count so we retry for ~3 hours
.build_with_total_retry_duration(Duration::from_secs(3 * 60 * 60));
// mean delay steps: 1.5s, 3s, 6s, 12s, 24s, 48s, 96s, 192s,
// 384s, 768s, 1536s, 3072s, 3600s, 3600s
// expected total delay: 13342.5s = 3.7h (least number of retries >= 3h)
assert_eq!(backoff.max_n_retries, 14);
Trait Implementations
sourceimpl Default for ExponentialBackoffBuilder
impl Default for ExponentialBackoffBuilder
sourcefn default() -> ExponentialBackoffBuilder
fn default() -> ExponentialBackoffBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for ExponentialBackoffBuilder
impl Send for ExponentialBackoffBuilder
impl Sync for ExponentialBackoffBuilder
impl Unpin for ExponentialBackoffBuilder
impl UnwindSafe for ExponentialBackoffBuilder
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<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>
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