Skip to content

Commit

Permalink
fix: Fix deprecation warning in Sidekiq 7.2
Browse files Browse the repository at this point in the history
Fixes #195
  • Loading branch information
adamlogic committed Feb 7, 2024
1 parent ab9dbe0 commit 9e22147
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
4 changes: 3 additions & 1 deletion judoscale-sidekiq/lib/judoscale/sidekiq/metrics_collector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ def collect
if track_busy_jobs?
busy_counts = Hash.new { |h, k| h[k] = 0 }
::Sidekiq::Workers.new.each do |pid, tid, work|
payload = work["payload"]
# Sidekiq 7.2 added a new Sidekiq::Work type; hash access is deprecated
payload = work.payload if work.respond_to?(:payload)
payload ||= work["payload"]
# payload is unparsed in Sidekiq 7
payload = JSON.parse(payload) if payload.is_a?(String)
busy_counts[payload["queue"]] += 1
Expand Down
3 changes: 2 additions & 1 deletion sample-apps/sidekiq-sample/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }

gem "puma", "~> 5.0"

gem "sidekiq", "~> 6.4"
# gem "sidekiq", "~> 7.2"
gem "sidekiq", ">= 6.0", "< 7.0"

# Need to reference all locally, otherwise it'd use the the gemspecs to try to find each gem,
# but we want to test against the local dev versions of them, not the released gems.
Expand Down
18 changes: 9 additions & 9 deletions sample-apps/sidekiq-sample/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
PATH
remote: ../../judoscale-rails
specs:
judoscale-rails (1.5.0)
judoscale-ruby (= 1.5.0)
judoscale-rails (1.5.3)
judoscale-ruby (= 1.5.3)
railties

PATH
remote: ../../judoscale-ruby
specs:
judoscale-ruby (1.5.0)
judoscale-ruby (1.5.3)

PATH
remote: ../../judoscale-sidekiq
specs:
judoscale-sidekiq (1.5.0)
judoscale-ruby (= 1.5.0)
judoscale-sidekiq (1.5.3)
judoscale-ruby (= 1.5.3)
sidekiq (>= 5.0)

GEM
Expand All @@ -40,7 +40,7 @@ GEM
tzinfo (~> 2.0)
builder (3.2.4)
concurrent-ruby (1.2.0)
connection_pool (2.3.0)
connection_pool (2.4.1)
crass (1.0.6)
erubi (1.12.0)
i18n (1.12.0)
Expand Down Expand Up @@ -76,8 +76,8 @@ GEM
thor (~> 1.0)
zeitwerk (~> 2.5)
rake (13.0.6)
redis (4.8.0)
sidekiq (6.5.8)
redis (4.8.1)
sidekiq (6.5.12)
connection_pool (>= 2.2.5, < 3)
rack (~> 2.0)
redis (>= 4.5.0, < 5)
Expand All @@ -101,7 +101,7 @@ DEPENDENCIES
judoscale-sidekiq!
puma (~> 5.0)
railties (~> 7.0.1)
sidekiq (~> 6.4)
sidekiq (>= 6.0, < 7.0)

BUNDLED WITH
2.3.9
3 changes: 2 additions & 1 deletion sample-apps/sidekiq-sample/bin/dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash

heroku local
# Show all warnings: https://www.fastruby.io/blog/exploring-ruby-warnings.html
RUBYOPT="-W2" heroku local

0 comments on commit 9e22147

Please sign in to comment.