mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Refactor, changes
This commit is contained in:
parent
7448351d73
commit
86ca02f1d9
2 changed files with 7 additions and 6 deletions
|
@ -9,6 +9,8 @@ HEAD
|
||||||
- Remove `freeze` calls on String constants. This is superfluous with Ruby
|
- Remove `freeze` calls on String constants. This is superfluous with Ruby
|
||||||
2.3+ and `frozen_string_literal: true`. [#3759]
|
2.3+ and `frozen_string_literal: true`. [#3759]
|
||||||
- Fix use of AR middleware outside of Rails [#3787]
|
- Fix use of AR middleware outside of Rails [#3787]
|
||||||
|
- Sidekiq::Worker `sidekiq_retry_in` block can now return nil or 0 to use
|
||||||
|
the default backoff delay [#3796, dsalahutdinov]
|
||||||
|
|
||||||
5.1.1
|
5.1.1
|
||||||
-----------
|
-----------
|
||||||
|
|
|
@ -61,7 +61,6 @@ module Sidekiq
|
||||||
include Sidekiq::Util
|
include Sidekiq::Util
|
||||||
|
|
||||||
DEFAULT_MAX_RETRY_ATTEMPTS = 25
|
DEFAULT_MAX_RETRY_ATTEMPTS = 25
|
||||||
USE_DEFAULT_RETRY_FORMULA = 0
|
|
||||||
|
|
||||||
def initialize(options = {})
|
def initialize(options = {})
|
||||||
@max_retries = Sidekiq.options.merge(options).fetch(:max_retries, DEFAULT_MAX_RETRY_ATTEMPTS)
|
@max_retries = Sidekiq.options.merge(options).fetch(:max_retries, DEFAULT_MAX_RETRY_ATTEMPTS)
|
||||||
|
@ -206,9 +205,9 @@ module Sidekiq
|
||||||
end
|
end
|
||||||
|
|
||||||
def delay_for(worker, count, exception)
|
def delay_for(worker, count, exception)
|
||||||
if worker && worker.sidekiq_retry_in_block
|
if worker && worker.sidekiq_retry_in_block
|
||||||
custom_retry_in = retry_in(worker, count, exception)
|
custom_retry_in = retry_in(worker, count, exception).to_i
|
||||||
return custom_retry_in if custom_retry_in != USE_DEFAULT_RETRY_FORMULA
|
return custom_retry_in if custom_retry_in > 0
|
||||||
end
|
end
|
||||||
seconds_to_delay(count)
|
seconds_to_delay(count)
|
||||||
end
|
end
|
||||||
|
@ -220,10 +219,10 @@ module Sidekiq
|
||||||
|
|
||||||
def retry_in(worker, count, exception)
|
def retry_in(worker, count, exception)
|
||||||
begin
|
begin
|
||||||
worker.sidekiq_retry_in_block.call(count, exception).to_i
|
worker.sidekiq_retry_in_block.call(count, exception)
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
handle_exception(e, { context: "Failure scheduling retry using the defined `sidekiq_retry_in` in #{worker.class.name}, falling back to default" })
|
handle_exception(e, { context: "Failure scheduling retry using the defined `sidekiq_retry_in` in #{worker.class.name}, falling back to default" })
|
||||||
USE_DEFAULT_RETRY_FORMULA
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue