backoff icon indicating copy to clipboard operation
backoff copied to clipboard

Example configuring exponential backoff?

Open tobymurray opened this issue 2 years ago • 1 comments

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?

tobymurray avatar Nov 14 '21 17:11 tobymurray

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.

svet-b avatar Oct 19 '22 07:10 svet-b