Expand description
Defines traits for retry policies and some common implementations.
The client libraries automatically retry RPCs when (1) they fail due to transient errors and the RPC is idempotent, (2) or failed before an RPC was started. That is, when it is safe to attempt the RPC more than once.
Applications may override the default behavior, increasing the retry attempts, or changing what errors are considered safe to retry.
This module defines the traits for retry policies and some common implementations.
To configure the default throttler for a client, use ClientBuilder::with_retry_policy. To configure the retry policy used for a specific request, use RequestOptionsBuilder::with_retry_policy.
§Examples
Create a policy that only retries transient errors, and retries for at most 10 seconds or at most 5 attempts: whichever limit is reached first stops the retry loop.
use std::time::Duration;
let policy = Aip194Strict.with_time_limit(Duration::from_secs(10)).with_attempt_limit(5);Create a policy that retries on any error (even when unsafe to do so), and stops retrying after 5 attempts or 10 seconds, whichever limit is reached first stops the retry loop.
use std::time::Duration;
let policy = AlwaysRetry.with_time_limit(Duration::from_secs(10)).with_attempt_limit(5);Structs§
- Aip194
Strict - A retry policy that strictly follows AIP-194.
- Always
Retry - A retry policy that retries all errors.
- Client
Timeout - A retry policy decorator that continues on client timeouts.
- Limited
Attempt Count - A retry policy decorator that limits the number of attempts.
- Limited
Elapsed Time - A retry policy decorator that limits the total time in the retry loop.
- Limited
Elapsed Time Error - Error indicating that the maximum elapsed time for retries has been exceeded.
- Never
Retry - A retry policy that never retries.
- Retry
Policy Arg - A helper type to use RetryPolicy in client and request options.
- TooMany
Requests - A retry policy decorator that continues on
ResourceExhaustedorTOO_MANY_REQUESTS.
Traits§
- Retry
Policy - Determines how errors are handled in the retry loop.
- Retry
Policy Ext - Extension trait for
RetryPolicy