Skip to content

Latest commit

 

History

History
83 lines (50 loc) · 2.57 KB

README.md

File metadata and controls

83 lines (50 loc) · 2.57 KB

Sidekiq::SilentRetry

Ruby

sidekiq-silent-retry is a middleware for Sidekiq that allows for silent retries of jobs. This gem intercepts exceptions raised during job execution and re-raises under a different exception class, so that tracing services can ignore them. Only the last exception is raised with the original exception.

Instalation

Add this line to your application's Gemfile:

gem 'sidekiq-silent-retry'

And then execute:

$ bundle install

Usage

Configuration

1. Specify the error class for Silent Retry (optional)

You can specify a custom error class for silent retries. This is useful for making error tracing services ignore these errors.

Create an initializer file (e.g., config/initializers/sidekiq_silent_retry.rb) and add the following:

Sidekiq::SilentRetry.silent_retry_error_class = MySilentRetryError

2. Mark jobs for Silent Retry

In your Sidekiq job class, configure the silent_retry option to control silent retries. The silent_retry option can be:

  • false / nil: Disabled (default).
  • true: Always enabled, no matter the error.
  • Some class / Array of classes: Only exceptions of said class(es) will be silently retried.

You can also set warn_after option to start raise warnings after a number of retries instead of only the last one.

class MyJob
  include Sidekiq::Job

  sidekiq_options silent_retry: true

  def perform(*args)
    # Your job logic here
  end
end

class MyJob
  include Sidekiq::Job

  sidekiq_options silent_retry: [CommonError, CommonError2], warn_after: 2

  def perform(*args)
    # Your job logic here
  end
end

Dependencies

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/trusted/sidekiq-silent-retry. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Sidekiq::SilentRetry project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.