Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composable retry policies #58

Open
rucek opened this issue Dec 4, 2023 · 1 comment
Open

Composable retry policies #58

rucek opened this issue Dec 4, 2023 · 1 comment
Labels
enhancement New feature or request retries

Comments

@rucek
Copy link
Contributor

rucek commented Dec 4, 2023

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))
@zkerriga
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request retries
Projects
None yet
Development

No branches or pull requests

2 participants