Skip to main content

RetryPolicy

Struct RetryPolicy 

Source
pub struct RetryPolicy {
    pub initial_ms: u64,
    pub factor: u64,
    pub cap_ms: u64,
    pub give_up_ms: u64,
}
Expand description

Exponential backoff: initial_ms, then ×factor, capped at cap_ms; give up once give_up_ms have passed since the first send (§7.3: 5 s, ×2, 60 s, 24 h).

A resend also waits until the host has been silent for initial_ms (at most cap_ms longer): while its messages are still arriving, the answer is most likely among them.

Fields§

§initial_ms: u64

Delay before the first retry.

§factor: u64

Multiplier per attempt.

§cap_ms: u64

Largest delay.

§give_up_ms: u64

Total time after which a request is abandoned.

Implementations§

Source§

impl RetryPolicy

Source

pub const SPEC: Self

The §7.3 schedule.

Source

pub fn delay(&self, attempt: u32) -> u64

The delay after send number attempt (1 = the first send): 5 s, 10 s, 20 s, 40 s, then 60 s.

Source

pub fn refused_delay(&self, attempt: u32) -> u64

The delay after a transient error on send number attempt: 2 s, 4 s, 8 s, … 60 s, never longer than RetryPolicy::delay.

Source

pub fn next_at( &self, now_ms: u64, attempt: u32, error: Option<&ErrorBody>, ) -> u64

The next send time after send number attempt at now_ms: the backoff, or after a transient error its RetryPolicy::refused_delay or, if later, its retry_after_ms.

Source

pub const fn resend_now( &self, due_ms: u64, heard_ms: Option<u64>, now_ms: u64, ) -> bool

Whether a resend due at due_ms goes out at now_ms, the host last heard at heard_ms: once the host has been silent for initial_ms, or cap_ms after it was due, whatever the host is sending.

Source

pub const fn expired(&self, first_ms: u64, now_ms: u64) -> bool

Whether a request first sent at first_ms is abandoned at now_ms.

Trait Implementations§

Source§

impl Clone for RetryPolicy

Source§

fn clone(&self) -> RetryPolicy

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 Copy for RetryPolicy

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 Eq for RetryPolicy

Source§

impl PartialEq for RetryPolicy

Source§

fn eq(&self, other: &RetryPolicy) -> 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> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.