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

Have a parameter to supply a proc that is only called on the final failure #72

Open
jcobian opened this issue Mar 5, 2019 · 0 comments

Comments

@jcobian
Copy link
Contributor

jcobian commented Mar 5, 2019

Currently the on_retry parameter is called each time the passed in block of code raises a matching exception.

I am proposing that there be a on_final_failure (or similarly named) parameter which is a proc that is called after all retries have been exhausted.

The use case is that:

  • sometimes I'd like to perform a different action once all the retries have finished
  • sometimes I only want to perform an action once all the retries are finished.

I know there are current ways to do this outside of the gem, but I think the following interface could be nice:

do_this_on_each_retry = Proc.new { }
do_this_on_final_retry = Proc.new { }
Retriable.retriable(on_retry: do_this_on_each_retry, on_final_failure: do_this_on_final_retry) do
  # code here..
end

This allows me to have custom logic for the final failure, while still allowing the error to be raised by Retriable

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

No branches or pull requests

1 participant