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

Merge pull request #784 from lulalala/retry-colculation-as-method

Makes retry time calculation easier to monkey-patch
This commit is contained in:
Mike Perham 2013-03-20 07:37:59 -07:00
commit 299ed69ea5

View file

@ -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