pub struct ReconnectPolicy {
pub max_attempts: u32,
pub initial_backoff: Duration,
pub max_backoff: Duration,
pub multiplier: f64,
}Expand description
Reconnection policy for a WebSocket feed.
Controls exponential-backoff reconnect behaviour. Build with
ReconnectPolicy::new or use Default for sensible defaults.
Fields§
§max_attempts: u32Maximum number of reconnect attempts before giving up.
initial_backoff: DurationInitial backoff delay for the first reconnect attempt.
max_backoff: DurationMaximum backoff delay (cap for exponential growth).
multiplier: f64Multiplier applied to the backoff on each successive attempt (must be >= 1.0).
Implementations§
Source§impl ReconnectPolicy
impl ReconnectPolicy
Sourcepub fn new(
max_attempts: u32,
initial_backoff: Duration,
max_backoff: Duration,
multiplier: f64,
) -> Result<Self, StreamError>
pub fn new( max_attempts: u32, initial_backoff: Duration, max_backoff: Duration, multiplier: f64, ) -> Result<Self, StreamError>
Build a reconnect policy with explicit parameters.
Returns an error if multiplier < 1.0 (which would cause backoff to
shrink over time) or if max_attempts == 0.
Sourcepub fn backoff_for_attempt(&self, attempt: u32) -> Duration
pub fn backoff_for_attempt(&self, attempt: u32) -> Duration
Backoff duration for attempt N (0-indexed).
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