use retry_if::{ExponentialBackoffConfig, retry};
use std::time::Duration;
use tokio::time::{Instant, pause};
const BACKOFF_CONFIG: ExponentialBackoffConfig = ExponentialBackoffConfig {
max_retries: 5,
t_wait: Duration::from_secs(3),
backoff: 1.0,
t_wait_max: None,
backoff_max: None,
};
#[tokio::test]
async fn test_retry_if() {
pause();
fn retry_if(_: &()) -> bool {
true
}
#[retry(BACKOFF_CONFIG, retry_if)]
async fn method() {}
let start = Instant::now();
method().await;
let end = Instant::now();
let duration = end - start;
assert!(duration > Duration::from_secs(15));
assert!(duration < Duration::from_millis(15100));
}