Skip to main content

Backoff

Struct Backoff 

Source
#[non_exhaustive]
pub struct Backoff { pub initial: Duration, pub multiplier: u32, pub max: Option<Duration>, pub healthy: Duration, pub timeout: Option<Duration>, }
Expand description

When to redial after a failure, and when to give up, once a session has been established.

A session is established once the peer accepts the connection credential or drains the session with a GOAWAY, or, on a version with no answer to the credential (moq-lite 03/04), once it stays up past healthy. Before then nothing retries: a failed walk, or a session closed sooner, ends the policy.

initial and multiplier set the wait before each retry, max caps it, and healthy decides which sessions count as failed attempts. The delays carry jitter, so a fleet knocked offline together does not reconnect in lockstep. timeout bounds every failure; a settled rejection, malformed protocol input, or invalid local configuration stops retrying. A GOAWAY naming no new URI is no failure: a restarting peer sends one to each session until it goes, and each of those serves, so it restarts the timeout instead.

A GOAWAY off a healthy session migrates at once, unless the run of redirects, among sessions that each lived less than max, has looped back through an endpoint. The loop check keeps one endpoint, so it catches a cycle within a few laps rather than at the first revisit: A to B, B to C, C to B is followed once before it is caught. Peers redirecting in a loop then wait out this backoff and count against the timeout.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§initial: Duration

Delay before the first redial. Later delays grow from it, so zero turns retry waiting off entirely; an immediate close still counts as a failed attempt and spends the timeout. Defaults to 1 s.

§multiplier: u32

Growth of the delay after each failure. 0 or 1 keeps it constant. Defaults to 2.

§max: Option<Duration>

Cap on the delay, which caps initial too. None leaves it uncapped. Defaults to 5 s.

§healthy: Duration

How long a session must stay up to count as healthy. Must be nonzero. Defaults to 1 s.

Where the peer never answers the connection credential, as on moq-lite 03/04, the first healthy session establishes the policy, so failures retry from then on. Elsewhere only the peer’s answer or a GOAWAY establishes it, however long a session stays up. A healthy session’s end resets the delay and the timeout. One that ends sooner is a failed attempt, so a peer that accepts and then drops every session still escalates the delay and exhausts the timeout.

§timeout: Option<Duration>

How long to keep retrying before giving up. None (the default) retries forever, so an outage of any length recovers on its own; a caller that can react to a persistent failure sets one. Zero gives up at the first failure.

No new walk of the peer’s addresses starts once it has passed, but one under way finishes: each address but the last gets up to 5 s, and the last runs to Config::timeout, so a handshake slower than this still lands. Giving up can therefore take up to one whole walk longer. Resets after a healthy session outside a redirect loop.

Trait Implementations§

Source§

impl Clone for Backoff

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

Source§

impl Debug for Backoff

Source§

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

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

impl Default for Backoff

Source§

fn default() -> Self

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

impl Eq for Backoff

Source§

impl PartialEq for Backoff

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 Backoff

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more