pub struct RetryFutureConfig<BackoffT, OnRetryT> { /* private fields */ }
Expand description
Configuration describing how to retry a future.
This is useful if you have many futures you want to retry in the same way.
Implementations§
Source§impl<BackoffT, OnRetryT> RetryFutureConfig<BackoffT, OnRetryT>
impl<BackoffT, OnRetryT> RetryFutureConfig<BackoffT, OnRetryT>
Sourcepub fn max_delay(self, delay: Duration) -> Self
pub fn max_delay(self, delay: Duration) -> Self
Set the max duration to sleep between each attempt.
Sourcepub fn no_backoff(self) -> RetryFutureConfig<NoBackoff, OnRetryT>
pub fn no_backoff(self) -> RetryFutureConfig<NoBackoff, OnRetryT>
Remove the backoff strategy.
This will make the future be retried immediately without any delay in between attempts.
Sourcepub fn exponential_backoff(
self,
initial_delay: Duration,
) -> RetryFutureConfig<ExponentialBackoff, OnRetryT>
pub fn exponential_backoff( self, initial_delay: Duration, ) -> RetryFutureConfig<ExponentialBackoff, OnRetryT>
Use exponential backoff for retrying the future.
The first delay will be initial_delay
and afterwards the delay will double every time.
Sourcepub fn fixed_backoff(
self,
delay: Duration,
) -> RetryFutureConfig<FixedBackoff, OnRetryT>
pub fn fixed_backoff( self, delay: Duration, ) -> RetryFutureConfig<FixedBackoff, OnRetryT>
Use a fixed backoff for retrying the future.
The delay between attempts will always be delay
.
Sourcepub fn linear_backoff(
self,
delay: Duration,
) -> RetryFutureConfig<LinearBackoff, OnRetryT>
pub fn linear_backoff( self, delay: Duration, ) -> RetryFutureConfig<LinearBackoff, OnRetryT>
Use a linear backoff for retrying the future.
The delay will be delay * attempt
so it’ll scale linear with the attempt.
Sourcepub fn custom_backoff<B>(
self,
backoff_strategy: B,
) -> RetryFutureConfig<B, OnRetryT>
pub fn custom_backoff<B>( self, backoff_strategy: B, ) -> RetryFutureConfig<B, OnRetryT>
Use a custom backoff specified by some function.
See RetryFuture::custom_backoff
for more details.
Sourcepub fn on_retry<F>(self, f: F) -> RetryFutureConfig<BackoffT, F>
pub fn on_retry<F>(self, f: F) -> RetryFutureConfig<BackoffT, F>
Some async computation that will be spawned before each retry.
See RetryFuture::on_retry
for more details.
Trait Implementations§
Source§impl<BackoffT: Clone, OnRetryT: Clone> Clone for RetryFutureConfig<BackoffT, OnRetryT>
impl<BackoffT: Clone, OnRetryT: Clone> Clone for RetryFutureConfig<BackoffT, OnRetryT>
Source§fn clone(&self) -> RetryFutureConfig<BackoffT, OnRetryT>
fn clone(&self) -> RetryFutureConfig<BackoffT, OnRetryT>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<BackoffT, OnRetryT> Debug for RetryFutureConfig<BackoffT, OnRetryT>where
BackoffT: Debug,
impl<BackoffT, OnRetryT> Debug for RetryFutureConfig<BackoffT, OnRetryT>where
BackoffT: Debug,
Source§impl<BackoffT: PartialEq, OnRetryT: PartialEq> PartialEq for RetryFutureConfig<BackoffT, OnRetryT>
impl<BackoffT: PartialEq, OnRetryT: PartialEq> PartialEq for RetryFutureConfig<BackoffT, OnRetryT>
Source§fn eq(&self, other: &RetryFutureConfig<BackoffT, OnRetryT>) -> bool
fn eq(&self, other: &RetryFutureConfig<BackoffT, OnRetryT>) -> bool
self
and other
values to be equal, and is used by ==
.