1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use std::time::Duration;
use futures::IntoFuture;
use super::future::{retry, Sleep, RetryFuture};
mod jittered;
mod limited_retries;
mod limited_delay;
pub mod decorators;
pub trait RetryStrategy {
fn delay(&mut self) -> Option<Duration>;
fn jitter(self) -> decorators::Jittered<Self> where Self: Sized {
jittered::jitter(self)
}
fn limit_retries(self, max_retries: usize) -> decorators::LimitedRetries<Self> where Self: Sized {
limited_retries::limit_retries(self, max_retries)
}
fn limit_delay(self, max_delay: Duration) -> decorators::LimitedDelay<Self> where Self: Sized {
limited_delay::limit_delay(self, max_delay)
}
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 {
retry(sleep, self, action)
}
}