ox icon indicating copy to clipboard operation
ox copied to clipboard

Composable retry policies

Open rucek opened this issue 2 years ago • 1 comments

The current retry mechanism allows to provide a single policy for retrying the operation. Once this policy is "exhausted", i.e. when it's done retrying without success, it gives up.

We'd like to be able to compose multiple policies, so that more than one can be tried in the attempt to run the operation. For example, we might want to make a couple of immediate retries (with no delay) and, if still unsuccessful, retry indefinitely with exponential backoff.

The above could be written with a hypothetical fallbackTo combinator like:

val policy: RetryPolicy = RetryPolicy.immediate(3).fallbackTo(RetryPolicy.backoffForever(100.millis))

rucek avatar Dec 04 '23 15:12 rucek

Hi, @rucek! I made solution to compose Schedules so we can construct policies like:

RetryPolicy(Schedule.Immediate(1).fallbackTo(Schedule.Delay(2, 2.seconds)))

RetryPolicy(Schedule.Delay(2, 1.second).fallbackTo(Schedule.Backoff.forever(2.seconds)))

but I am not sure about the design of it. Please, have a look at my request

zkerriga avatar Apr 27 '24 21:04 zkerriga