Enum fred::types::ReconnectPolicy
source · pub enum ReconnectPolicy {
Constant {
attempts: u32,
max_attempts: u32,
delay: u32,
jitter: u32,
},
Linear {
attempts: u32,
max_attempts: u32,
max_delay: u32,
delay: u32,
jitter: u32,
},
Exponential {
attempts: u32,
max_attempts: u32,
min_delay: u32,
max_delay: u32,
mult: u32,
jitter: u32,
},
}Expand description
The type of reconnection policy to use. This will apply to every connection used by the client.
Use a max_attempts value of 0 to retry forever.
Variants§
Constant
Wait a constant amount of time between reconnect attempts, in ms.
Linear
Backoff reconnection attempts linearly, adding delay each time.
Exponential
Backoff reconnection attempts exponentially, multiplying the last delay by mult each time.
Implementations§
source§impl ReconnectPolicy
impl ReconnectPolicy
sourcepub fn new_constant(max_attempts: u32, delay: u32) -> ReconnectPolicy
pub fn new_constant(max_attempts: u32, delay: u32) -> ReconnectPolicy
Create a new reconnect policy with a constant backoff.
sourcepub fn new_linear(
max_attempts: u32,
max_delay: u32,
delay: u32,
) -> ReconnectPolicy
pub fn new_linear( max_attempts: u32, max_delay: u32, delay: u32, ) -> ReconnectPolicy
Create a new reconnect policy with a linear backoff.
sourcepub fn new_exponential(
max_attempts: u32,
min_delay: u32,
max_delay: u32,
mult: u32,
) -> ReconnectPolicy
pub fn new_exponential( max_attempts: u32, min_delay: u32, max_delay: u32, mult: u32, ) -> ReconnectPolicy
Create a new reconnect policy with an exponential backoff.
sourcepub fn set_jitter(&mut self, jitter_ms: u32)
pub fn set_jitter(&mut self, jitter_ms: u32)
Set the amount of jitter to add to each reconnect delay.
Default: 50 ms
sourcepub fn next_delay(&mut self) -> Option<u64>
pub fn next_delay(&mut self) -> Option<u64>
Calculate the next delay, incrementing attempts in the process.
Trait Implementations§
source§impl Clone for ReconnectPolicy
impl Clone for ReconnectPolicy
source§fn clone(&self) -> ReconnectPolicy
fn clone(&self) -> ReconnectPolicy
Returns a copy 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
source§impl Default for ReconnectPolicy
impl Default for ReconnectPolicy
source§impl PartialEq for ReconnectPolicy
impl PartialEq for ReconnectPolicy
impl Eq for ReconnectPolicy
impl StructuralPartialEq 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 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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)§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> 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>
Converts
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>
Converts
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