From 1885fcf5db9f7e3dc504e464971a3dbe652aa087 Mon Sep 17 00:00:00 2001 From: Filip Bartuzi Date: Wed, 9 Sep 2015 14:13:57 +0100 Subject: [PATCH] Map retry_in period to integer According to [wiki](https://github.com/mperham/sidekiq/wiki/Error-Handling). The return value of the block must be an integer. However many users like to use 1.hour / 2.days / 34.seconds syntax from `Activesupport::Duration`. All Activesupport::Duration instances can be mapped to integer with `to_i` method. Lets map it than! ``` # The current retry count is yielded. The return value of the block must be # an integer. It is used as the delay, in seconds. sidekiq_retry_in do |count| 10 * (count + 1) # (i.e. 10, 20, 30, 40) end ``` --- lib/sidekiq/middleware/server/retry_jobs.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sidekiq/middleware/server/retry_jobs.rb b/lib/sidekiq/middleware/server/retry_jobs.rb index 2a64150f..990f7c3e 100644 --- a/lib/sidekiq/middleware/server/retry_jobs.rb +++ b/lib/sidekiq/middleware/server/retry_jobs.rb @@ -181,7 +181,7 @@ module Sidekiq def retry_in(worker, count) begin - worker.sidekiq_retry_in_block.call(count) + worker.sidekiq_retry_in_block.call(count).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