Skip to main content

ReconnectPolicy

Struct ReconnectPolicy 

Source
pub struct ReconnectPolicy {
    pub max_attempts: u32,
    pub initial_backoff: Duration,
    pub max_backoff: Duration,
    pub total_budget: Duration,
    pub failure_cooldown: Duration,
}
Expand description

Bounds on bringing a connection back.

The entire point of this machinery is killing a transfer that hangs forever, so a reconnect loop that can spin forever would reintroduce the bug in a new costume. Every field here exists to make that unreachable: attempts are counted, backoff is capped, and the whole thing runs under one wall-clock timeout.

Fields§

§max_attempts: u32

Dial attempts per revival, including the first. 0 disables reviving.

§initial_backoff: Duration

Pause before the second attempt. Doubles each round, capped at max_backoff.

§max_backoff: Duration

Ceiling on the backoff, so a server that is refusing connections is not hammered and the wait between attempts stays legible.

§total_budget: Duration

Hard wall-clock ceiling on one revival, dial and authentication and every backoff included.

This is the bound that matters: the whole revival runs inside a single timeout of this length, so no attempt, however wedged, can outlive it.

§failure_cooldown: Duration

How long a failed revival’s verdict stands before another caller is allowed to try again.

Without it, each of a deep pipeline’s callers pays the full total_budget in turn against a server that is plainly gone.

Trait Implementations§

Source§

impl Clone for ReconnectPolicy

Source§

fn clone(&self) -> ReconnectPolicy

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 ReconnectPolicy

Source§

impl Debug for ReconnectPolicy

Source§

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

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

impl Default for ReconnectPolicy

Source§

fn default() -> Self

The shipping bounds.

Sized for the failures that actually recover — a Wi-Fi roam (1–5 s), a share flapping, a switch relearning a port — and deliberately NOT for a full NAS reboot (30–90 s). Sitting on a frozen transfer for minutes on the chance the box comes back is the behavior this whole effort exists to delete; surfacing a typed error at a minute lets the consumer retry the file, ask the user, or give up, all of which beat a silent stall.

Four attempts at 0.5 s → 1 s → 2 s of backoff leave the budget almost entirely to the dials themselves.

Source§

impl Eq for ReconnectPolicy

Source§

impl PartialEq for ReconnectPolicy

Source§

fn eq(&self, other: &ReconnectPolicy) -> 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 ReconnectPolicy

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.