pub struct RetryConfig {
pub max_attempts: usize,
pub initial_delay: Duration,
pub max_delay: Duration,
pub backoff_factor: f64,
pub connection_timeout: Duration,
}Expand description
Configuration for connection retry behavior.
Fields§
§max_attempts: usizeMaximum number of retry attempts.
Set to usize::MAX for infinite retries (daemon mode).
initial_delay: DurationInitial delay before first retry.
max_delay: DurationMaximum delay between retries (ceiling for exponential backoff).
backoff_factor: f64Backoff multiplier (e.g., 2.0 = double delay each retry).
connection_timeout: DurationTimeout for each individual connection attempt.
Implementations§
Source§impl RetryConfig
impl RetryConfig
Sourcepub fn startup() -> Self
pub fn startup() -> Self
Fast-fail retry for initial startup connection.
Attempts connection 20 times with exponential backoff, failing after approximately 30 seconds total. Use this during daemon startup to detect configuration errors quickly.
§Backoff Schedule
Attempt Delay Cumulative
------- ----- ----------
1 500ms 500ms
2 750ms 1.25s
3 1.12s 2.37s
...
20 30s ~45s (total)Sourcepub fn daemon() -> Self
pub fn daemon() -> Self
Infinite retry for long-running daemon (never give up!).
Retries forever with exponential backoff capped at 5 minutes. Use this for runtime reconnection after initial startup succeeds.
§Backoff Schedule
Attempt Delay Reasoning
------- ----- ---------
1 1s Immediate transient retry
2 2s Brief network blip
3 4s DNS propagation
4 8s Container restart
5 16s Service recovery
6 32s Load balancer failover
7 64s Datacenter maintenance
8 128s Extended outage
9 256s Multi-hour incident
10+ 300s Cap at 5 minutes, retry foreverReal-world example: DNS outages can last 24+ hours. This ensures the daemon automatically recovers without manual restart.
Sourcepub fn delay_for_attempt(&self, attempt: usize) -> Duration
pub fn delay_for_attempt(&self, attempt: usize) -> Duration
Calculate delay for a given attempt number (1-indexed).
Trait Implementations§
Source§impl Clone for RetryConfig
impl Clone for RetryConfig
Source§fn clone(&self) -> RetryConfig
fn clone(&self) -> RetryConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RetryConfig
impl Debug for RetryConfig
Auto Trait Implementations§
impl Freeze for RetryConfig
impl RefUnwindSafe for RetryConfig
impl Send for RetryConfig
impl Sync for RetryConfig
impl Unpin for RetryConfig
impl UnwindSafe for RetryConfig
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more