pub enum ReconnectStrategy {
Fail,
ExponentialBackoff {
base: Duration,
factor: f64,
max_duration: Option<Duration>,
max_retries: Option<usize>,
timeout: Option<Duration>,
},
FibonacciBackoff {
base: Duration,
max_duration: Option<Duration>,
max_retries: Option<usize>,
timeout: Option<Duration>,
},
FixedInterval {
interval: Duration,
max_retries: Option<usize>,
timeout: Option<Duration>,
},
}
Expand description
Represents the strategy to apply when attempting to reconnect the client to the server.
Variants§
Fail
A retry strategy that will fail immediately if a reconnect is attempted.
ExponentialBackoff
A retry strategy driven by exponential back-off.
Fields
max_duration: Option<Duration>
Represents the maximum duration to wait between attempts. None indicates no limit.
FibonacciBackoff
A retry strategy driven by the fibonacci series.
Fields
max_duration: Option<Duration>
Represents the maximum duration to wait between attempts. None indicates no limit.
FixedInterval
A retry strategy driven by a fixed interval.
Implementations§
Source§impl ReconnectStrategy
impl ReconnectStrategy
pub async fn reconnect<T: Reconnectable>( &mut self, reconnectable: &mut T, ) -> Result<()>
Sourcepub fn is_exponential_backoff(&self) -> bool
pub fn is_exponential_backoff(&self) -> bool
Returns true if this strategy is the exponential backoff variant.
Sourcepub fn is_fibonacci_backoff(&self) -> bool
pub fn is_fibonacci_backoff(&self) -> bool
Returns true if this strategy is the fibonacci backoff variant.
Sourcepub fn is_fixed_interval(&self) -> bool
pub fn is_fixed_interval(&self) -> bool
Returns true if this strategy is the fixed interval variant.
Sourcepub fn max_duration(&self) -> Option<Duration>
pub fn max_duration(&self) -> Option<Duration>
Returns the maximum duration between reconnect attempts, or None if there is no limit.
Sourcepub fn max_retries(&self) -> Option<usize>
pub fn max_retries(&self) -> Option<usize>
Returns the maximum reconnect attempts the strategy will perform, or None if will attempt forever.
Trait Implementations§
Source§impl Clone for ReconnectStrategy
impl Clone for ReconnectStrategy
Source§fn clone(&self) -> ReconnectStrategy
fn clone(&self) -> ReconnectStrategy
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more