mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Use default retry interval in sidekiq_retry_in
This commit is contained in:
parent
1aad7b52ee
commit
611f7cd31f
2 changed files with 12 additions and 1 deletions
|
@ -215,7 +215,8 @@ module Sidekiq
|
|||
|
||||
def retry_in(worker, count, exception)
|
||||
begin
|
||||
worker.sidekiq_retry_in_block.call(count, exception).to_i
|
||||
custom_retry_in = worker.sidekiq_retry_in_block.call(count, exception)
|
||||
custom_retry_in.nil? ? nil : custom_retry_in.to_i
|
||||
rescue Exception => e
|
||||
handle_exception(e, { context: "Failure scheduling retry using the defined `sidekiq_retry_in` in #{worker.class.name}, falling back to default" })
|
||||
nil
|
||||
|
|
|
@ -247,11 +247,16 @@ class TestRetry < Sidekiq::Test
|
|||
end
|
||||
end
|
||||
|
||||
class SpecialError < StandardError
|
||||
end
|
||||
|
||||
class CustomWorkerWithException
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_retry_in do |count, exception|
|
||||
case exception
|
||||
when SpecialError
|
||||
nil
|
||||
when ArgumentError
|
||||
count * 4
|
||||
else
|
||||
|
@ -280,6 +285,11 @@ class TestRetry < Sidekiq::Test
|
|||
assert_equal 4, handler.__send__(:delay_for, CustomWorkerWithException, 2, StandardError.new)
|
||||
end
|
||||
|
||||
it "retries with a default delay and exception in case of configured with nil" do
|
||||
refute_equal 8, handler.__send__(:delay_for, CustomWorkerWithException, 2, SpecialError.new)
|
||||
refute_equal 4, handler.__send__(:delay_for, CustomWorkerWithException, 2, SpecialError.new)
|
||||
end
|
||||
|
||||
it "retries with a custom delay without exception" do
|
||||
assert_equal 4, handler.__send__(:delay_for, CustomWorkerWithoutException, 2, StandardError.new)
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue