rust-tokio-retry
rust-tokio-retry copied to clipboard
Immediate retry?
Hello, Just checked sources - looks like Delay is the only option used for retry.
Are there any way to produce "Immediate" retry?
Thank you,
The interface to Retry and RetryIf looks like:
pub fn spawn<T: IntoIterator<IntoIter = I, Item = Duration>>(
strategy: T,
action: A,
condition: C
) -> RetryIf<I, A, C>
So you should be able to implement an Iterator
that returns Duration
s in your desired pattern.
If you want the first to be an immediate retry, and then a Exponential pattern, it would look like:
std::iter::once(Duration::from_secs(0))
.chain(
ExponentialBackoff::from_millis(100)
.factor(3)
.max_delay(Duration::from_secs(3))
)