-
Notifications
You must be signed in to change notification settings - Fork 11
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
Fix max_retries Method #31
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
/pkg/ | ||
/spec/reports/ | ||
/tmp/ | ||
sidekiq-instrument-* |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -13,10 +13,17 @@ def worker_dog_options(worker) | |||||||||||||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
def max_retries(worker) | ||||||||||||||||||||||||||||||||||||||
retries = worker.class.get_sidekiq_options['retry'] || Sidekiq[:max_retries] | ||||||||||||||||||||||||||||||||||||||
return Sidekiq[:max_retries] if retries.to_s.eql?("true") | ||||||||||||||||||||||||||||||||||||||
return 0 if retries.eql?("false") | ||||||||||||||||||||||||||||||||||||||
retries | ||||||||||||||||||||||||||||||||||||||
retries = fetch_worker_retry(worker) | ||||||||||||||||||||||||||||||||||||||
case retries.to_s | ||||||||||||||||||||||||||||||||||||||
when "true" | ||||||||||||||||||||||||||||||||||||||
Sidekiq[:max_retries] | ||||||||||||||||||||||||||||||||||||||
when "false" | ||||||||||||||||||||||||||||||||||||||
0 | ||||||||||||||||||||||||||||||||||||||
when "" | ||||||||||||||||||||||||||||||||||||||
Sidekiq[:max_retries] | ||||||||||||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||||||||||||
retries | ||||||||||||||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But, honestly, we should not be passing in boolean values at all, Sidekiq is clearly written with numbers in mind (and just doesn't validate that) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh neat, I didn't know that syntax was allowed in Ruby - good shout thanks. I agree that it's unfortunate we have to handle so many cases because there doesn't really seem to be a good standardized way we're doing it :( |
||||||||||||||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
private | ||||||||||||||||||||||||||||||||||||||
|
@@ -29,6 +36,10 @@ def class_name(worker) | |||||||||||||||||||||||||||||||||||||
worker.class.name.gsub('::', '_') | ||||||||||||||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
def fetch_worker_retry(worker) | ||||||||||||||||||||||||||||||||||||||
worker.class.get_sidekiq_options['retry'] | ||||||||||||||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
def underscore(string) | ||||||||||||||||||||||||||||||||||||||
string.gsub(/::/, '/'). | ||||||||||||||||||||||||||||||||||||||
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). | ||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module Sidekiq | ||
module Instrument | ||
VERSION = '0.7.0' | ||
VERSION = '0.7.1' | ||
end | ||
end |
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 was causing the worker to always default to the global
Sidekiq[:max_retries]
value even ifworker.class.get_sidekiq_options['retry']
was set to false, which is NOT the intended behavior.