Skip to content

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

@jcobian

Description

@jcobian

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions