Struct futures_backoff::Strategy [] [src]

pub struct Strategy { /* fields omitted */ }

Configurable retry strategy.

Implements Default, which returns an exponential backoff strategy with a delay of 1 second and a maximum of 5 retries.

Example

let strategy = Strategy::default()
    .with_max_retries(3);

let future = strategy.retry(|| {
    // do some real-world stuff here...
    future::ok::<u32, ::std::io::Error>(42)
});

Methods

impl Strategy
[src]

[src]

Creates a retry strategy driven by exponential back-off.

The specified duration will be multiplied by 2^n, where n is the number of failed attempts.

[src]

Creates a retry strategy driven by a fibonacci back-off.

The specified duration will be multiplied by fib(n), where n is the number of failed attempts.

Depending on the problem at hand, a fibonacci retry strategy might perform better and lead to better throughput than the ExponentialBackoff strategy.

See "A Performance Comparison of Different Backoff Algorithms under Different Rebroadcast Probabilities for MANETs." for more details.

[src]

Creates a retry strategy driven by a fixed delay.

[src]

Sets the maximum delay between two attempts.

By default there is no maximum.

[src]

Sets the maximum number of retry attempts.

By default a retry will be attempted 5 times before giving up.

[src]

Enables or disables jitter on the delay.

Jitter will introduce a random variance to the retry strategy, which can be helpful to mitigate the "Thundering Herd" problem.

[src]

Run the given action, and use this strategy to retry on failure.

[src]

Run the given action, and use this strategy to retry on failure if the error satisfies a given condition.

Trait Implementations

impl Debug for Strategy
[src]

[src]

Formats the value using the given formatter. Read more

impl Default for Strategy
[src]

[src]

Returns the "default value" for a type. Read more

Auto Trait Implementations

impl Send for Strategy

impl Sync for Strategy