Struct ReconnectOptions
#[non_exhaustive]pub struct ReconnectOptions {
pub initial_delay: Duration,
pub max_delay: Duration,
pub multiplier: BackoffMultiplier,
pub jitter: Jitter,
pub stop_on_fatal_rejection: bool,
}Expand description
Configuration for automatic reconnection with exponential backoff.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.initial_delay: DurationInitial delay before the first reconnection attempt.
max_delay: DurationMaximum delay between reconnection attempts.
multiplier: BackoffMultiplierMultiplicative factor applied after each failed attempt.
jitter: JitterRandom jitter fraction applied to each delay.
stop_on_fatal_rejection: boolWhether a CONNACK rejection that needs operator intervention
(unsupported protocol version, invalid client id, bad credentials,
not authorized, banned) stops the reconnect loop with a final
Rejected status. Defaults to
false: such rejections are often fixed server-side, so the client
keeps retrying with backoff.
Implementations§
§impl ReconnectOptions
impl ReconnectOptions
pub const fn new() -> Self
pub const fn new() -> Self
Creates options with sensible defaults: 1 s initial delay, 30 s maximum delay, 2x multiplier, 25% jitter, retry on every rejection.
pub const fn initial_delay(self, delay: Duration) -> Self
pub const fn initial_delay(self, delay: Duration) -> Self
Sets the initial delay before the first reconnection attempt.
pub const fn max_delay(self, delay: Duration) -> Self
pub const fn max_delay(self, delay: Duration) -> Self
Sets the maximum delay between reconnection attempts.
pub const fn multiplier(self, multiplier: BackoffMultiplier) -> Self
pub const fn multiplier(self, multiplier: BackoffMultiplier) -> Self
Sets the multiplicative factor applied after each failed attempt.
pub const fn jitter(self, jitter: Jitter) -> Self
pub const fn jitter(self, jitter: Jitter) -> Self
Sets the random jitter fraction applied to each delay.
pub const fn stop_on_fatal_rejection(self, stop: bool) -> Self
pub const fn stop_on_fatal_rejection(self, stop: bool) -> Self
Sets whether a fatal CONNACK rejection stops the reconnect loop (see
stop_on_fatal_rejection).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ReconnectOptions
impl RefUnwindSafe for ReconnectOptions
impl Send for ReconnectOptions
impl Sync for ReconnectOptions
impl Unpin for ReconnectOptions
impl UnwindSafe for ReconnectOptions
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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