pub struct RetryPolicy {
pub max_retries: u32,
pub initial_backoff: Duration,
pub max_backoff: Duration,
pub multiplier: f64,
pub retryable_statuses: Vec<u16>,
}Expand description
Controls how failed requests are retried.
By default the SDK retries up to 2 times on connection errors and on the
statuses listed in RetryPolicy::retryable_statuses (which includes the
documented 429 Too Many Requests and 529 Overloaded), using exponential
backoff with jitter, and honoring the Retry-After response header.
Set RetryPolicy::none (or max_retries: 0) to disable retries.
Fields§
§max_retries: u32Maximum number of retries after the initial attempt. 0 disables
retries.
initial_backoff: DurationBackoff before the first retry.
max_backoff: DurationUpper bound for any single backoff.
multiplier: f64Multiplier applied to the backoff after each attempt.
retryable_statuses: Vec<u16>HTTP statuses considered transient.
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn should_retry_status(&self, status: StatusCode) -> bool
pub fn should_retry_status(&self, status: StatusCode) -> bool
Whether a response status is retryable under this policy.
Sourcepub fn backoff_for(&self, attempt: u32) -> Duration
pub fn backoff_for(&self, attempt: u32) -> Duration
The delay before retry attempt attempt (0 = first retry), including
up to 25% random jitter and capped at RetryPolicy::max_backoff.
This function is total: non-finite or non-positive multipliers fall
back to 2.0, and overflow saturates at max_backoff instead of
panicking.
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§fn clone(&self) -> RetryPolicy
fn clone(&self) -> RetryPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more