lib/sidekiq/job_retry.rb in sidekiq-5.1.1 vs lib/sidekiq/job_retry.rb in sidekiq-5.1.2

- old
+ new

@@ -1,5 +1,6 @@ +# frozen_string_literal: true require 'sidekiq/scheduled' require 'sidekiq/api' module Sidekiq ## @@ -202,20 +203,24 @@ default end end def delay_for(worker, count, exception) - worker && worker.sidekiq_retry_in_block && retry_in(worker, count, exception) || seconds_to_delay(count) + 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 # delayed_job uses the same basic formula def seconds_to_delay(count) (count ** 4) + 15 + (rand(30)*(count+1)) end 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" }) nil end end