Skip to main content

Module backoff_policy

Module backoff_policy 

Source
Expand description

Defines traits for backoff policies and a common implementations.

The client libraries automatically retry RPCs based on the RetryPolicy configured for the request or client. Even when the policy determines that an operation is safe to retry, the client library does not retry failed requests immediately, as the service may need time to recover. Exponential backoff is a well known algorithm to find an acceptable delay between retries, but some application may need slight variations on this algorithm. The client libraries use a BackoffPolicy to configure the delays between retry attempts.

While exponential backoff improves the system behavior when there are small faults, something like a RetryThrottler may be needed to improve recovery times in larger failures.

To configure the default retry backoff policy for a client, use ClientBuilder::with_backoff_policy. To configure the retry backoff policy used for a specific request, use RequestOptionsBuilder::with_backoff_policy.

§Example

use std::time::Duration;

let policy = ExponentialBackoffBuilder::new()
    .with_initial_delay(Duration::from_millis(100))
    .with_maximum_delay(Duration::from_secs(5))
    .with_scaling(4.0)
    .build()?;

Structs§

BackoffPolicyArg
A helper type to use BackoffPolicy in client and request options.

Traits§

BackoffPolicy
Defines the trait implemented by all backoff strategies.