#[non_exhaustive]pub struct RetryPolicy {
pub max_retries: u32,
pub backoff_initial: Duration,
pub backoff_max: Duration,
pub backoff_jitter: f64,
pub http_statuses: BTreeSet<u16>,
pub respect_retry_after: bool,
pub retry_connection_errors: bool,
pub retry_timeouts: bool,
pub predicate: Option<RetryPredicate>,
pub budget: Option<Duration>,
}Expand description
How failed requests are retried.
Start from RetryPolicy::default or RetryPolicy::none and adjust with the builder methods
(or set the public fields directly).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.max_retries: u32Retries after the first attempt; 0 disables retries. Default 2.
backoff_initial: DurationFirst backoff delay, doubled per attempt up to backoff_max; zero disables backoff. Default 0.5s.
backoff_max: DurationMaximum backoff delay; zero disables backoff. Default 5s.
backoff_jitter: f64Fraction of each delay randomly subtracted, in [0, 1]. Default 0.25.
http_statuses: BTreeSet<u16>Statuses that are retried. Default 408, 429 and 500–599 (which includes TypeSafe’s 529).
respect_retry_after: boolHonor retry-after-ms / Retry-After. Default true.
retry_connection_errors: boolRetry Error::Connection. Default true.
retry_timeouts: boolRetry Error::Timeout. Default true.
predicate: Option<RetryPredicate>Extra predicate; returning true also triggers a retry.
budget: Option<Duration>Total budget per SDK call including attempts and delays; None = unlimited. Default 30s.
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn max_retries(self, n: u32) -> Self
pub fn max_retries(self, n: u32) -> Self
Set max_retries.
Sourcepub fn statuses(self, statuses: impl IntoIterator<Item = u16>) -> Self
pub fn statuses(self, statuses: impl IntoIterator<Item = u16>) -> Self
Replace the retryable status set.
Sourcepub fn respect_retry_after(self, yes: bool) -> Self
pub fn respect_retry_after(self, yes: bool) -> Self
Whether to honor retry-after-ms / Retry-After.
Sourcepub fn retry_connection_errors(self, yes: bool) -> Self
pub fn retry_connection_errors(self, yes: bool) -> Self
Whether to retry Error::Connection.
Sourcepub fn retry_timeouts(self, yes: bool) -> Self
pub fn retry_timeouts(self, yes: bool) -> Self
Whether to retry Error::Timeout.
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