-
Notifications
You must be signed in to change notification settings - Fork 46
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
Allow to disable retriable blocks #85
base: master
Are you sure you want to change the base?
Conversation
03f3c25
to
0b800f4
Compare
@@ -222,6 +222,17 @@ def increment_tries_with_exception(exception_class = nil) | |||
it "raises ArgumentError on invalid options" do | |||
expect { described_class.retriable(does_not_exist: 123) { increment_tries } }.to raise_error(ArgumentError) | |||
end | |||
|
|||
it "raises without retries when disabled" do | |||
begin |
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.
Style/RedundantBegin: Redundant begin block detected.
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.
This is needed because ruby < 2.5 requires explicit begin...ensure
inside blocks.
You could just do: # config/initializers/retriable.rb
Retriable.configure do |c|
if Rails.env.development?
c.tries = 1
end
end Right? |
Yes, for simple cases. I honestly do not remember, which specific example I had in mind. But from README changes you can see, how it also simplifies working with contexts. Sure, you can write something like this for each context: Retriable.configure do |c|
c.contexts[:google_api] = {
tries: Rails.env.test? ? 1 : 5,
base_interval: 3,
on: [
Net::ReadTimeout,
Signet::AuthorizationError,
Errno::ECONNRESET,
OpenSSL::SSL::SSLError
]
}
end But the proposed solution looks cleaner for me. |
This is primarily for testing convenience, but can be very useful in development, for example, when you want to quickly disable/reenable retrying.