Sidekiq::Retries
This subclasses the stock Sidekiq retries middleware to give you some additional options to conditionally retry jobs irrespective of whether retries are enabled for the job.
Installation
Add this line to your application's Gemfile:
gem 'sidekiq-retries'
Usage
class NoRetryJob
include Sidekiq::Worker
retry: false # or retry: 0
def perform
# force a retry
raise Sidekiq::Retries::Retry.new(RuntimeError.new('whatever happened'))
end
end
class RetryJob
include Sidekiq::Worker
retry: 25
def perform
# fail the job, don't retry it
raise Sidekiq::Retries::Fail.new(RuntimeError.new('whatever happened'))
end
end
Caveats
- Jobs with retry: 0 don't ever appear to show up in the Sidekiq 3 Dead queue
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request