1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Refactor, changes

This commit is contained in:
Mike Perham 2018-03-22 09:13:21 -07:00
parent 7448351d73
commit 86ca02f1d9
2 changed files with 7 additions and 6 deletions

View file

@ -9,6 +9,8 @@ HEAD
- Remove `freeze` calls on String constants. This is superfluous with Ruby
2.3+ and `frozen_string_literal: true`. [#3759]
- 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
-----------

View file

@ -61,7 +61,6 @@ module Sidekiq
include Sidekiq::Util
DEFAULT_MAX_RETRY_ATTEMPTS = 25
USE_DEFAULT_RETRY_FORMULA = 0
def initialize(options = {})
@max_retries = Sidekiq.options.merge(options).fetch(:max_retries, DEFAULT_MAX_RETRY_ATTEMPTS)
@ -206,9 +205,9 @@ module Sidekiq
end
def delay_for(worker, count, exception)
if worker && worker.sidekiq_retry_in_block
custom_retry_in = retry_in(worker, count, exception)
return custom_retry_in if custom_retry_in != USE_DEFAULT_RETRY_FORMULA
if worker && worker.sidekiq_retry_in_block
custom_retry_in = retry_in(worker, count, exception).to_i
return custom_retry_in if custom_retry_in > 0
end
seconds_to_delay(count)
end
@ -220,10 +219,10 @@ module Sidekiq
def retry_in(worker, count, exception)
begin
worker.sidekiq_retry_in_block.call(count, exception).to_i
worker.sidekiq_retry_in_block.call(count, exception)
rescue Exception => e
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