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

Dynamic retry policies #550

Merged
merged 4 commits into from
Jan 9, 2025
Merged

Dynamic retry policies #550

merged 4 commits into from
Jan 9, 2025

Conversation

cb372
Copy link
Owner

@cb372 cb372 commented Jan 6, 2025

Fixes #506.

When asking the retry policy to decide the next step, pass the result of the last attempt. Depending on the combinator, this could be a value or an error.

Before:

case class RetryPolicy[F[_]](
    decideNextRetry: RetryStatus => F[PolicyDecision]
)

After:

case class RetryPolicy[F[_], -Res](
    decideNextRetry: (Res, RetryStatus) => F[PolicyDecision]
)

This allows users to implement more exotic retry policies, e.g. choosing to retry some kinds of error quickly, but using exponential backoff for others. I've added RetryPolicies.dynamic to support that.

All the built-in policies maintain their existing behaviour: they ignore the action result and decide the next step based on static rules.

This was quite a noisy change because it involved adding a new type parameter to RetryPolicy.

cb372 added 4 commits January 6, 2025 12:10
When asking the retry policy to decide the next step, pass the result of
the last attempt. Depending on the combinator, this could be a value or
an error.

This allows users to implement more exotic retry policies, e.g. choosing
to retry some kinds of error quickly, but using exponential backoff for
others.

All the built-in policies maintain their existing behaviour: they ignore
the action result and decide the next step based on static rules.

This was quite a noisy change because it involved adding a new type
parameter to `RetryPolicy`.
"Dynamic" in the sense that it chooses a retry policy based on the
result of the last attempt. Depending on the combinator, that might be a
value or an error.
@cb372 cb372 force-pushed the dynamic-retry-policies branch from 69f8100 to deb663c Compare January 6, 2025 12:10
@cb372 cb372 merged commit 256e847 into v4 Jan 9, 2025
5 checks passed
@cb372 cb372 deleted the dynamic-retry-policies branch January 9, 2025 10:46
cb372 added a commit that referenced this pull request Jan 10, 2025
I forgot to update them as part of #550
cb372 added a commit that referenced this pull request Jan 10, 2025
I forgot to update them as part of #550
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.

2 participants