#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.initial: DurationDelay 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: u32Growth 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: DurationHow 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§
impl Copy for Backoff
impl Eq for Backoff
impl StructuralPartialEq for Backoff
Auto Trait Implementations§
impl Freeze for Backoff
impl RefUnwindSafe for Backoff
impl Send for Backoff
impl Sync for Backoff
impl Unpin for Backoff
impl UnsafeUnpin for Backoff
impl UnwindSafe for Backoff
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.