mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Makes retry time calculation easier to monkey-patch by changing it from
a constant proc to a method.
This commit is contained in:
parent
852bea5dfc
commit
e649006109
1 changed files with 5 additions and 2 deletions
|
@ -43,7 +43,6 @@ module Sidekiq
|
|||
|
||||
# delayed_job uses the same basic formula
|
||||
DEFAULT_MAX_RETRY_ATTEMPTS = 25
|
||||
DELAY = proc { |count| (count ** 4) + 15 + (rand(30)*(count+1)) }
|
||||
|
||||
def call(worker, msg, queue)
|
||||
yield
|
||||
|
@ -73,7 +72,7 @@ module Sidekiq
|
|||
end
|
||||
|
||||
if count < max_retry_attempts
|
||||
delay = DELAY.call(count)
|
||||
delay = seconds_to_delay(count)
|
||||
logger.debug { "Failure! Retry #{count} in #{delay} seconds" }
|
||||
retry_at = Time.now.to_f + delay
|
||||
payload = Sidekiq.dump_json(msg)
|
||||
|
@ -95,6 +94,10 @@ module Sidekiq
|
|||
end
|
||||
end
|
||||
|
||||
def seconds_to_delay(count)
|
||||
(count ** 4) + 15 + (rand(30)*(count+1))
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue