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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ability to combine Schedules for retries #129

Merged

Conversation

zkerriga
Copy link
Contributor

#58

I tried to make proposed syntax:

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

but found fallbackTo method on RetryPolicy a bit misleading, because with current design of retry classes we cannot easily compose different ResultPolicy and onRetry functions. Instead, I decided to make composable just Schedule classes.

I added Combination and CombinationForever subclasses by analogy so we can combine Finite schedules with both Finite and Infinite fallbacks, but I have a feeling that they add an unreasonable complication 馃 - feel free to reject it

P.S. it's my first opensource request

@adamw adamw requested a review from rucek April 27, 2024 21:17
Copy link
Member

@kciesielski kciesielski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congratulations on your first contribution! 馃榿
I added a few minor comments. I'd also like @rucek to take a look. The names Combination and CombinationForever feel like something that could be expressed with better words, but I'm not sure what would do the job. Naming is hard 馃

@zkerriga zkerriga requested a review from kciesielski May 12, 2024 17:32
@rucek
Copy link
Contributor

rucek commented May 14, 2024

Thanks for the contribution @zkerriga! This looks good too me, my only concerns are about the naming, which is indeed hard 馃槄. I think Combined and Combination are too general, since what we're doing is not a generic combination of Schedules, but a very specific one - a fallback to another Schedule.

I was thinking about renaming Combined to WithFallback, and Combination/CombinationForever to FallingBack/FallingBackForever, respectively. WDYT?

@kciesielski
Copy link
Member

FallingBackForever sounds so romantic <3

@adamw
Copy link
Member

adamw commented May 14, 2024

Since we are bikeshedding on names (the PR looks good, @zkerriga , let's get it merged & released :) ), how about simply andThen instead of fallbackTo? Wouldn't it be more intuitive, i.e., "retry 3 times, and then retry 5 times with a pause". The class representing the schedule could then be named Sequence (as there's a "first" and "second" schedule, that is, order matters)?

@zkerriga
Copy link
Contributor Author

Thank you for reviews! @adamw, it's an interesting idea about Sequence and andThen method, but I decided to use Fallback naming from @rucek because it seems clearer to me and I don't think that making more than 1 fallback will be a popular thing.

@rucek
Copy link
Contributor

rucek commented May 14, 2024

I agree that although andThen and Sequence would make sense, it's the "fallback" naming that communicates the purpose more clearly.

@kciesielski kciesielski merged commit 4adb2bd into softwaremill:master May 15, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants