Trait tokio_retry::RetryStrategy
[−]
[src]
pub trait RetryStrategy { fn delay(&mut self) -> Option<Duration>; fn jitter(self) -> Jittered<Self> where Self: Sized { ... } fn limit_retries(self, max_retries: usize) -> LimitedRetries<Self> where Self: Sized { ... } fn limit_delay(self, max_delay: Duration) -> LimitedDelay<Self> where Self: Sized { ... } fn run<S, A, F>(self, sleep: S, action: F) -> RetryFuture<S, Self, A, F> where S: Sleep, Self: Sized, A: IntoFuture, F: FnMut() -> A { ... } }
Trait that specifies a retry behaviour.
Required Methods
fn delay(&mut self) -> Option<Duration>
If Some
is returned, causes a delay of the specified duration before the next attempt.
If None
is returned, causes no further attempts.
Provided Methods
fn jitter(self) -> Jittered<Self> where Self: Sized
Introduce full random jitter to the delay between attempts.
fn limit_retries(self, max_retries: usize) -> LimitedRetries<Self> where Self: Sized
Limit the number of retries.
fn limit_delay(self, max_delay: Duration) -> LimitedDelay<Self> where Self: Sized
Limit the delay between attempts.
fn run<S, A, F>(self, sleep: S, action: F) -> RetryFuture<S, Self, A, F> where S: Sleep, Self: Sized, A: IntoFuture, F: FnMut() -> A
Run the provided action, and if it fails, retry it using this strategy.
Implementors
impl<S: RetryStrategy> RetryStrategy for Jittered<S>
impl<S: RetryStrategy> RetryStrategy for LimitedRetries<S>
impl<S: RetryStrategy> RetryStrategy for LimitedDelay<S>
impl RetryStrategy for NoRetry
impl RetryStrategy for FixedInterval
impl RetryStrategy for ExponentialBackoff
impl<T> RetryStrategy for FromIterator<T> where T: IntoIterator<Item=Duration>