#[non_exhaustive]pub struct ReconnectPolicy {
pub enabled: bool,
pub initial_delay: Duration,
pub max_delay: Duration,
pub backoff_factor: f64,
pub max_retries: Option<u32>,
pub jitter: bool,
}Expand description
Policy controlling automatic reconnection behavior.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.enabled: boolWhether automatic reconnection is enabled.
initial_delay: DurationInitial delay before first reconnect attempt.
max_delay: DurationMaximum delay between reconnect attempts.
backoff_factor: f64Multiplier applied to delay after each failed attempt.
max_retries: Option<u32>Maximum number of retries. None = infinite.
jitter: boolAdd random jitter to delay to prevent thundering herd.
Implementations§
Source§impl ReconnectPolicy
impl ReconnectPolicy
Sourcepub fn delay_for_attempt(&self, attempt: u32) -> Duration
pub fn delay_for_attempt(&self, attempt: u32) -> Duration
Compute delay for the nth attempt (0-indexed).
Sourcepub fn should_retry(&self, attempts: u32) -> bool
pub fn should_retry(&self, attempts: u32) -> bool
Whether we should retry after the given number of attempts.
Trait Implementations§
Source§impl Clone for ReconnectPolicy
impl Clone for ReconnectPolicy
Source§fn clone(&self) -> ReconnectPolicy
fn clone(&self) -> ReconnectPolicy
Returns a duplicate of the value. Read more
1.0.0 · 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 ReconnectPolicy
impl Debug for ReconnectPolicy
Auto Trait Implementations§
impl Freeze for ReconnectPolicy
impl RefUnwindSafe for ReconnectPolicy
impl Send for ReconnectPolicy
impl Sync for ReconnectPolicy
impl Unpin for ReconnectPolicy
impl UnsafeUnpin for ReconnectPolicy
impl UnwindSafe for ReconnectPolicy
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