mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
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 ```
This commit is contained in:
parent
4154091ab0
commit
1885fcf5db
1 changed files with 1 additions and 1 deletions
|
@ -181,7 +181,7 @@ module Sidekiq
|
||||||
|
|
||||||
def retry_in(worker, count)
|
def retry_in(worker, count)
|
||||||
begin
|
begin
|
||||||
worker.sidekiq_retry_in_block.call(count)
|
worker.sidekiq_retry_in_block.call(count).to_i
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
handle_exception(e, { context: "Failure scheduling retry using the defined `sidekiq_retry_in` in #{worker.class.name}, falling back to default" })
|
handle_exception(e, { context: "Failure scheduling retry using the defined `sidekiq_retry_in` in #{worker.class.name}, falling back to default" })
|
||||||
nil
|
nil
|
||||||
|
|
Loading…
Reference in a new issue