pub struct ExponentialBackoffBuilder { /* private fields */ }

Implementations

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.

Set backoff exponent. Default 3.

See ExponentialBackoff::backoff_exponent.

Builds a ExponentialBackoff with the given maximum retries.

See ExponentialBackoff::max_n_retries.

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

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.