backoff
backoff copied to clipboard
Example configuring exponential backoff?
I want a greater duration between the initial failure and the first retry. The docs show a lot of examples with ExponentialBackoff::default()
, what's the recommended way to configure it? Is it sensible to do something like:
let backoff = ExponentialBackoff {
initial_interval: std::time::Duration::from_secs(1),
current_interval: std::time::Duration::from_secs(1),
..Default::default()
};
Does current_interval
need to be set to the same value as initial_interval
?
Not sure if better or worse, but the following also works:
let backoff = ExponentialBackoffBuilder::new()
.with_initial_interval(std::time::Duration::from_secs(1))
.build();
Either way, I agree that it would be best to have the correct (and least likely to break) approach documented.