-
Notifications
You must be signed in to change notification settings - Fork 46
Add ignore option to skip retries #107
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
base: master
Are you sure you want to change the base?
Conversation
kamui
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, just some comments and also if you could add this to the readme docs.
| ignore = local_config.ignore | ||
|
|
||
| exception_list = on.is_a?(Hash) ? on.keys : on | ||
| exception_list = on.is_a?(Hash) ? on.keys : [on].flatten |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you wrapping it in an array and flattening? Just in case on is a single Exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right yes. I was just making sure that this always returns an array, even if we pass a single object in the params.
lib/retriable.rb
Outdated
| return Timeout.timeout(timeout) { return yield(try) } if timeout | ||
| return yield(try) | ||
| rescue *[*exception_list] => exception | ||
| rescue *[*rescue_list] => exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we put on and ignore in an array and flatten it, do we still need this array splat expansion? This is here in case on is not an array, but you're with your changes on line 41-42, it's impossible now for this to not be an array.
| end | ||
|
|
||
| if ignore.is_a?(Hash) | ||
| raise if ignore_list.any? do |e| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should happen if the user puts the same exception in both lists? In this implementation, ignore will override on right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea it should do, also a test here: https://github.com/kamui/retriable/pull/107/files#diff-da878450c719751b2a3bde1a1916ebec1eb23f30c4f9e2d69d95fbfda1184646R162
| end | ||
| end | ||
|
|
||
| if ignore.is_a?(Hash) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this ignore check happen before the on check? Isn't it generally better if we raise as soon as we can since it'll shortcut checking the other exceptions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK can do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
@kamui thanks for the review. Updated with your comments and also added the readme. Cheers. |
|
Nice feature to have! |
6196a1e to
c448885
Compare
Add
:ignoreoption to retriable so that we can not retry exceptions that do not need one.