Enum distant_net::client::ReconnectStrategy
source · 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
Fields
base: DurationRepresents the initial time to wait between reconnect attempts.
factor: f64Factor to use when modifying the retry time, used as a multiplier.
max_duration: Option<Duration>Represents the maximum duration to wait between attempts. None indicates no limit.
A retry strategy driven by exponential back-off.
FibonacciBackoff
Fields
base: DurationRepresents the initial time to wait between reconnect attempts.
max_duration: Option<Duration>Represents the maximum duration to wait between attempts. None indicates no limit.
A retry strategy driven by the fibonacci series.
FixedInterval
Fields
interval: DurationRepresents the time between reconnect attempts.
A retry strategy driven by a fixed interval.
Implementations
sourceimpl 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
sourceimpl Clone for ReconnectStrategy
impl Clone for ReconnectStrategy
sourcefn clone(&self) -> ReconnectStrategy
fn clone(&self) -> ReconnectStrategy
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more