pub struct NetworkRetryPolicy {
pub enabled: bool,
pub max_attempts: u32,
pub initial_delay: Duration,
pub multiplier: f64,
pub max_delay: Duration,
pub jitter_factor: f64,
}Expand description
Reconnection and backoff policy for networked components.
Used in component config structs as a reconnect field:
[default.components.redis.reconnect]
max_attempts = 10
initial_delay_ms = 100
max_delay_ms = 30000Fields§
§enabled: boolWhether reconnection is enabled at all.
max_attempts: u32Maximum number of attempts before giving up. 0 means unlimited.
initial_delay: DurationBase delay for the first retry.
multiplier: f64Exponential backoff multiplier applied to each successive attempt.
max_delay: DurationMaximum delay cap regardless of computed backoff.
jitter_factor: f64Jitter factor in [0.0, 1.0]. Actual delay is base ± (base * jitter_factor / 2).
Implementations§
Source§impl NetworkRetryPolicy
impl NetworkRetryPolicy
Sourcepub fn delay_for(&self, attempt: u32) -> Duration
pub fn delay_for(&self, attempt: u32) -> Duration
Computes the sleep duration for a given zero-based attempt number.
Formula: clamp(initial * multiplier^attempt, 0, max_delay) with random jitter.
Sourcepub fn should_retry(&self, attempt: u32) -> bool
pub fn should_retry(&self, attempt: u32) -> bool
Returns true if another retry should be attempted.
attempt is zero-based: 0 = first attempt, 1 = first retry, etc.
Trait Implementations§
Source§impl Clone for NetworkRetryPolicy
impl Clone for NetworkRetryPolicy
Source§fn clone(&self) -> NetworkRetryPolicy
fn clone(&self) -> NetworkRetryPolicy
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NetworkRetryPolicy
impl Debug for NetworkRetryPolicy
Source§impl Default for NetworkRetryPolicy
impl Default for NetworkRetryPolicy
Source§impl<'de> Deserialize<'de> for NetworkRetryPolicy
impl<'de> Deserialize<'de> for NetworkRetryPolicy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for NetworkRetryPolicy
impl PartialEq for NetworkRetryPolicy
Source§fn eq(&self, other: &NetworkRetryPolicy) -> bool
fn eq(&self, other: &NetworkRetryPolicy) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for NetworkRetryPolicy
impl Serialize for NetworkRetryPolicy
impl StructuralPartialEq for NetworkRetryPolicy
Auto Trait Implementations§
impl Freeze for NetworkRetryPolicy
impl RefUnwindSafe for NetworkRetryPolicy
impl Send for NetworkRetryPolicy
impl Sync for NetworkRetryPolicy
impl Unpin for NetworkRetryPolicy
impl UnsafeUnpin for NetworkRetryPolicy
impl UnwindSafe for NetworkRetryPolicy
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
Mutably borrows from an owned value. Read more