Skip to content

Commit

Permalink
Replace fixed number with Sidekiq constant (#405)
Browse files Browse the repository at this point in the history
* Replace fixed number with Sidekiq constant

* fix type in CHANGELOG
  • Loading branch information
LJSkadi authored Apr 15, 2021
1 parent 2d24a36 commit 2ad4201
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
- Added 'ActionDispatch::Http::MimeNegotiation::InvalidType' (Rails 6.1) to
default ignore list. (#402, @jrochkind)
- Replaced fixed number for retries in Sidekiq Plugin with Sidekiq::JobRetry constant

## [4.8.0] - 2021-03-16
### Fixed
Expand Down
10 changes: 6 additions & 4 deletions lib/honeybadger/plugins/sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Honeybadger
module Plugins
module Sidekiq
class Middleware
def call(worker, msg, queue)
def call(_worker, _msg, _queue)
Honeybadger.clear!
yield
end
Expand All @@ -23,7 +23,7 @@ def call(worker, msg, queue)

if defined?(::Sidekiq::VERSION) && ::Sidekiq::VERSION > '3'
::Sidekiq.configure_server do |sidekiq|
sidekiq.error_handlers << lambda {|ex, params|
sidekiq.error_handlers << lambda { |ex, params|
job = params[:job] || params
job_retry = job['retry'.freeze]

Expand All @@ -37,13 +37,15 @@ def call(worker, msg, queue)
attempt = retry_count ? retry_count + 1 : 0

# Ensure we account for modified max_retries setting
retry_limit = job_retry == true ? (sidekiq.options[:max_retries] || 25) : job_retry.to_i
default_max_retry_attempts = defined?(::Sidekiq::JobRetry::DEFAULT_MAX_RETRY_ATTEMPTS) ? ::Sidekiq::JobRetry::DEFAULT_MAX_RETRY_ATTEMPTS : 25
retry_limit = job_retry == true ? (sidekiq.options[:max_retries] || default_max_retry_attempts) : job_retry.to_i

limit = [retry_limit, threshold].min

return if attempt < limit
end

opts = {parameters: params}
opts = { parameters: params }
if config[:'sidekiq.use_component']
opts[:component] = job['wrapped'.freeze] || job['class'.freeze]
opts[:action] = 'perform' if opts[:component]
Expand Down

0 comments on commit 2ad4201

Please sign in to comment.