Skip to main content

RetryPolicy

Struct RetryPolicy 

Source
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: f64

Fraction (0.0..=1.0) of each delay randomly shaved off; 0 = deterministic.

§retry_statuses: Vec<u16>§honor_retry_after: bool§max_retry_after: Duration

Upper bound applied to a server-supplied Retry-After.

§defer_over_cap: bool

When 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

Source

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.

Source

pub fn none() -> Self

Source

pub fn is_retryable_status(&self, status: u16) -> bool

Source

pub fn separate_budgets(&self) -> bool

True when either opt-in per-failure-kind budget is set; see RetryPolicy::max_transport_attempts.

Source

pub fn backoff(&self, retry: u32) -> Duration

Delay before retry number retry (1 = after the first failure).

Source

pub fn delay(&self, retry: u32, retry_after: Option<Duration>) -> Duration

Delay for a given failure: the larger of backoff and a (capped) Retry-After.

Trait Implementations§

Source§

impl Clone for RetryPolicy

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RetryPolicy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RetryPolicy

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for RetryPolicy

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RetryPolicy

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.