-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add retries #48
Comments
Thanks! That's a good start :) So first I think we might consider extending the wish-list a bit. One thing I'm currently lacking is to decide if retries should be continued or modified basing on the result - this can include both a successful result (e.g. As for including the schedule as a parameter to retry - I like this idea :). And that's because maybe we can try to unify Finally, the technical question - distinguishing |
There are a few concepts in
For composing retry policies, cats-retry offers operations like:
If overloading is too tricky, or turns out to be too difficult to handle for the user, we may consider predefined methods similar to cats-retry, like:
Bonus, can be left for implementation in the future: def op: T = ...
retryCond(op)(
delay(5.seconds).whenThrownA[DBConnectionException], // creates a ConditionalThrowableRetryPolicy
immediately.whenThrown {
case _: TransactionException => true
}
)
Similarly for other types of op: def op: Either[E, T] = ...
retryCond(op)(resultPolicies = List( // List[ConditionalRetryPolicy[T]]
delay(5.seconds).when[T](_.code == 300),
immediately.when[T](_.code != 300),
retryableErrorPolicies = List( // List[ConditionalRetryPolicy[E]]
immediately.whenMatches[E] {
case _: MyError1 | _: MyError2 => true
}
)
) Conditional policies would act like composed with 'join', which is IMO enough. |
Retries
Background
We'd like to have a retry mechanism supporting:
f: => T
,Either
, i.e.f: => Either[E, T]
Try
, i.e.f: => Try[T]
Proposed API
Heavily inspired by https://github.com/softwaremill/retry
Questions/doubts
retry
, e.g.f: => T
andf: Try[T]
/f: Either[E, T]
without using dedicated functions liketried
/either
?The text was updated successfully, but these errors were encountered: