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: u32Dial attempts per revival, including the first. 0 disables reviving.
initial_backoff: DurationPause before the second attempt. Doubles each round, capped at
max_backoff.
max_backoff: DurationCeiling on the backoff, so a server that is refusing connections is not hammered and the wait between attempts stays legible.
total_budget: DurationHard 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: DurationHow 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
impl Clone for ReconnectPolicy
Source§fn clone(&self) -> ReconnectPolicy
fn clone(&self) -> ReconnectPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ReconnectPolicy
Source§impl Debug for ReconnectPolicy
impl Debug for ReconnectPolicy
Source§impl Default for ReconnectPolicy
impl Default for ReconnectPolicy
Source§fn default() -> Self
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.