pub struct RetryPolicy {
pub max_attempts: u32,
pub initial_backoff: Duration,
pub max_backoff: Duration,
pub multiplier: f64,
pub jitter: f64,
pub retry_statuses: Vec<u16>,
pub honor_retry_after: bool,
pub max_retry_after: Duration,
pub defer_over_cap: bool,
pub max_transport_attempts: Option<u32>,
pub max_status_attempts: Option<u32>,
}Expand description
Retry/backoff policy. max_attempts counts total tries (1 = no retry).
Fields§
§max_attempts: u32§initial_backoff: Duration§max_backoff: Duration§multiplier: f64§jitter: f64Fraction (0.0..=1.0) of each delay randomly shaved off; 0 = deterministic.
retry_statuses: Vec<u16>§honor_retry_after: bool§max_retry_after: DurationUpper bound applied to a server-supplied Retry-After.
defer_over_cap: boolWhen a server-supplied Retry-After is longer than max_retry_after, stop retrying
instead of sleeping the capped time and asking again too early. The call then returns
the response (or HttpError::Status with the full, uncapped retry_after) so the
caller can schedule the next try durably, for example with QuotaSchedule.
Default false (the old behaviour: sleep the capped delay and retry).
max_transport_attempts: Option<u32>Opt-in separate budget for transport/timeout failures: the most attempts that may
end in such a failure (1 = the first transport failure is final). None (the
default) keeps the legacy single shared counter, where only max_attempts binds.
When either budget is set, failures count only against their own budget, backoff
advances per budget, alternating failures never reset either counter, and
max_attempts remains the finite cap on total physical attempts.
max_status_attempts: Option<u32>Opt-in separate budget for retryable-status failures; see
RetryPolicy::max_transport_attempts.
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn defers(&self, retry_after: Option<Duration>) -> bool
pub fn defers(&self, retry_after: Option<Duration>) -> bool
True when retry_after is honoured, defer_over_cap is set and the server asked
for longer than max_retry_after: the retry loop should return, not sleep.
pub fn none() -> Self
pub fn is_retryable_status(&self, status: u16) -> bool
Sourcepub fn separate_budgets(&self) -> bool
pub fn separate_budgets(&self) -> bool
True when either opt-in per-failure-kind budget is set; see
RetryPolicy::max_transport_attempts.