sidekiq 6.4.0 → 6.5.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sidekiq might be problematic. Click here for more details.

Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/Changes.md +50 -1
  3. data/README.md +6 -1
  4. data/bin/sidekiq +3 -3
  5. data/bin/sidekiqload +70 -66
  6. data/bin/sidekiqmon +1 -1
  7. data/lib/sidekiq/api.rb +78 -65
  8. data/lib/sidekiq/cli.rb +46 -37
  9. data/lib/sidekiq/client.rb +42 -28
  10. data/lib/sidekiq/component.rb +64 -0
  11. data/lib/sidekiq/delay.rb +1 -1
  12. data/lib/sidekiq/extensions/action_mailer.rb +2 -2
  13. data/lib/sidekiq/extensions/active_record.rb +2 -2
  14. data/lib/sidekiq/extensions/class_methods.rb +2 -2
  15. data/lib/sidekiq/extensions/generic_proxy.rb +3 -3
  16. data/lib/sidekiq/fetch.rb +17 -15
  17. data/lib/sidekiq/job_logger.rb +15 -27
  18. data/lib/sidekiq/job_retry.rb +27 -26
  19. data/lib/sidekiq/job_util.rb +15 -9
  20. data/lib/sidekiq/launcher.rb +54 -52
  21. data/lib/sidekiq/logger.rb +8 -18
  22. data/lib/sidekiq/manager.rb +28 -25
  23. data/lib/sidekiq/middleware/chain.rb +22 -13
  24. data/lib/sidekiq/middleware/current_attributes.rb +4 -0
  25. data/lib/sidekiq/middleware/i18n.rb +6 -4
  26. data/lib/sidekiq/middleware/modules.rb +19 -0
  27. data/lib/sidekiq/monitor.rb +1 -1
  28. data/lib/sidekiq/paginator.rb +8 -8
  29. data/lib/sidekiq/processor.rb +38 -38
  30. data/lib/sidekiq/rails.rb +15 -8
  31. data/lib/sidekiq/redis_client_adapter.rb +154 -0
  32. data/lib/sidekiq/redis_connection.rb +81 -48
  33. data/lib/sidekiq/ring_buffer.rb +29 -0
  34. data/lib/sidekiq/scheduled.rb +11 -10
  35. data/lib/sidekiq/testing/inline.rb +4 -4
  36. data/lib/sidekiq/testing.rb +37 -36
  37. data/lib/sidekiq/transaction_aware_client.rb +45 -0
  38. data/lib/sidekiq/version.rb +1 -1
  39. data/lib/sidekiq/web/csrf_protection.rb +2 -2
  40. data/lib/sidekiq/web/helpers.rb +5 -5
  41. data/lib/sidekiq/web.rb +3 -3
  42. data/lib/sidekiq/worker.rb +20 -17
  43. data/lib/sidekiq.rb +98 -30
  44. data/web/assets/javascripts/application.js +58 -26
  45. data/web/assets/stylesheets/application.css +1 -0
  46. data/web/locales/pt-br.yml +27 -9
  47. data/web/views/_summary.erb +1 -1
  48. data/web/views/busy.erb +3 -3
  49. metadata +8 -5
  50. data/lib/sidekiq/exception_handler.rb +0 -27
  51. data/lib/sidekiq/util.rb +0 -108
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9622b2851203b0c5a80695ab7801ca77e15dc63a641ae79132cda9a2fcbe0cc6
4
- data.tar.gz: dd943a02d2cf910f51866d02254f3a7845cb159735bd54d223dd7127a1fbd2fa
3
+ metadata.gz: dedc78179d612e64435e57f0f6644c2645c06ffdc24151c9ad51df4035b51efa
4
+ data.tar.gz: 5987eba09190793cfccbff56066b54b5308a1fe74be7551cb5b9d6d03d256c3a
5
5
  SHA512:
6
- metadata.gz: 65bcd542866d8699ecf5958d81a15fd322cd1c51dfc1dbc6a8b15402b70862510c134e2b0ed9f9dbcdbb4dea3a59c1d12878ff926145e503079a59896f279ff3
7
- data.tar.gz: 36143e85dc7fd4611f8a43fe39788dc590725ac63a827fbc174916da2d59fdadb3fb64fa0d819c4ef90694f6f292ea15f7fb58fb29f368c0a06c5b90f1b4bca7
6
+ metadata.gz: 9a26b5eb6e2248870f07ede054cac8330b52ad548d27b40d3950b6d985ef5ef8359e4dfc062757dc4b479036f0b2716bacfc821a20bd63413ea7c3f772bc6ead
7
+ data.tar.gz: 46a35f7f27693364b1b6077e602d3f69e476508654157f48fcd457a70bbcdb563f8515812ef37abae207604596e1d42f78132ac54471109f913e87c11a707cdb
data/Changes.md CHANGED
@@ -2,6 +2,49 @@
2
2
 
3
3
  [Sidekiq Changes](https://github.com/mperham/sidekiq/blob/main/Changes.md) | [Sidekiq Pro Changes](https://github.com/mperham/sidekiq/blob/main/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/mperham/sidekiq/blob/main/Ent-Changes.md)
4
4
 
5
+ 6.5.0
6
+ ---------
7
+
8
+ - Substantial refactoring of Sidekiq server internals, part of a larger effort
9
+ to reduce Sidekiq's internal usage of global methods and data, see [docs/component.md](docs/component.md),
10
+ [docs/global_to_local.md](docs/global_to_local.md) and [docs/middleware.md](docs/middleware.md).
11
+ - **Add beta support for the `redis-client` gem**. This will become the default Redis driver in Sidekiq 7.0. [#5298]
12
+ Read more: https://github.com/mperham/sidekiq/wiki/Using-redis-client
13
+ - **Add beta support for DB transaction-aware client** [#5291]
14
+ Add this line to your initializer and any jobs created during a transaction
15
+ will only be pushed to Redis **after the transaction commits**. You will need to add the
16
+ `after_commit_everywhere` gem to your Gemfile.
17
+ ```ruby
18
+ Sidekiq.transactional_push!
19
+ ```
20
+ This feature does not have a lot of production usage yet; please try it out and let us
21
+ know if you have any issues. It will be fully supported in Sidekiq 7.0 or removed if it
22
+ proves problematic.
23
+ - Fix regression with middleware arguments [#5312]
24
+
25
+ 6.4.2
26
+ ---------
27
+
28
+ - Strict argument checking now runs after client-side middleware [#5246]
29
+ - Fix page events with live polling [#5184]
30
+ - Many under-the-hood changes to remove all usage of the term "worker"
31
+ from the Sidekiq codebase and APIs. This mostly involved RDoc and local
32
+ variable names but a few constants and public APIs were changed. The old
33
+ APIs will be removed in Sidekiq 7.0.
34
+ ```
35
+ Sidekiq::DEFAULT_WORKER_OPTIONS -> Sidekiq.default_job_options
36
+ Sidekiq.default_worker_options -> Sidekiq.default_job_options
37
+ Sidekiq::Queues["default"].jobs_by_worker(HardJob) -> Sidekiq::Queues["default"].jobs_by_class(HardJob)
38
+ ```
39
+
40
+ 6.4.1
41
+ ---------
42
+
43
+ - Fix pipeline/multi deprecations in redis-rb 4.6
44
+ - Fix sidekiq.yml YAML load errors on Ruby 3.1 [#5141]
45
+ - Sharding support for `perform_bulk` [#5129]
46
+ - Refactor job logger for SPEEEEEEED
47
+
5
48
  6.4.0
6
49
  ---------
7
50
 
@@ -27,7 +70,6 @@ bin/rails generate sidekiq:job ProcessOrderJob
27
70
  ```
28
71
  - Fix job retries losing CurrentAttributes [#5090]
29
72
  - Tweak shutdown to give long-running threads time to cleanup [#5095]
30
- - Add keyword arguments support in extensions
31
73
 
32
74
  6.3.1
33
75
  ---------
@@ -312,6 +354,13 @@ See the [Logging wiki page](https://github.com/mperham/sidekiq/wiki/Logging) for
312
354
  - Integrate the StandardRB code formatter to ensure consistent code
313
355
  styling. [#4114, gearnode]
314
356
 
357
+ 5.2.10
358
+ ---------
359
+
360
+ - Backport fix for CVE-2022-23837.
361
+ - Migrate to `exists?` for redis-rb.
362
+ - Lock redis-rb to <4.6 to avoid deprecations.
363
+
315
364
  5.2.9
316
365
  ---------
317
366
 
data/README.md CHANGED
@@ -36,7 +36,7 @@ Sidekiq 6.0 supports Rails 5.0+ but does not require it.
36
36
  Installation
37
37
  -----------------
38
38
 
39
- gem install sidekiq
39
+ bundle add sidekiq
40
40
 
41
41
 
42
42
  Getting Started
@@ -80,6 +80,11 @@ Useful resources:
80
80
  Every Friday morning is Sidekiq happy hour: I video chat and answer questions.
81
81
  See the [Sidekiq support page](https://sidekiq.org/support.html) for details.
82
82
 
83
+ Contributing
84
+ -----------------
85
+
86
+ Please see [the contributing guidelines](https://github.com/mperham/sidekiq/blob/main/.github/contributing.md).
87
+
83
88
 
84
89
  License
85
90
  -----------------
data/bin/sidekiq CHANGED
@@ -4,7 +4,7 @@
4
4
  # RUBYOPT=-w bundle exec sidekiq
5
5
  $TESTING = false
6
6
 
7
- require_relative '../lib/sidekiq/cli'
7
+ require_relative "../lib/sidekiq/cli"
8
8
 
9
9
  def integrate_with_systemd
10
10
  return unless ENV["NOTIFY_SOCKET"]
@@ -32,8 +32,8 @@ begin
32
32
  rescue => e
33
33
  raise e if $DEBUG
34
34
  if Sidekiq.error_handlers.length == 0
35
- STDERR.puts e.message
36
- STDERR.puts e.backtrace.join("\n")
35
+ warn e.message
36
+ warn e.backtrace.join("\n")
37
37
  else
38
38
  cli.handle_exception e
39
39
  end
data/bin/sidekiqload CHANGED
@@ -4,19 +4,22 @@
4
4
  # RUBYOPT=-w bundle exec sidekiq
5
5
  $TESTING = false
6
6
 
7
- #require 'ruby-prof'
8
- require 'bundler/setup'
7
+ # require "ruby-prof"
8
+ require "bundler/setup"
9
9
  Bundler.require(:default, :load_test)
10
10
 
11
- require_relative '../lib/sidekiq/cli'
12
- require_relative '../lib/sidekiq/launcher'
11
+ require_relative "../lib/sidekiq/cli"
12
+ require_relative "../lib/sidekiq/launcher"
13
13
 
14
- include Sidekiq::Util
14
+ if ENV["SIDEKIQ_REDIS_CLIENT"]
15
+ Sidekiq::RedisConnection.adapter = :redis_client
16
+ end
15
17
 
16
18
  Sidekiq.configure_server do |config|
17
19
  config.options[:concurrency] = 10
18
- config.redis = { db: 13, port: 6380, driver: :hiredis }
19
- config.options[:queues] << 'default'
20
+ config.redis = {db: 13, port: 6380}
21
+ # config.redis = { db: 13, port: 6380, driver: :hiredis}
22
+ config.options[:queues] << "default"
20
23
  config.logger.level = Logger::ERROR
21
24
  config.average_scheduled_poll_interval = 2
22
25
  config.reliable! if defined?(Sidekiq::Pro)
@@ -29,53 +32,50 @@ class LoadWorker
29
32
  1
30
33
  end
31
34
 
32
- def perform(idx, ts=nil)
33
- puts(Time.now.to_f - ts) if ts != nil
34
- #raise idx.to_s if idx % 100 == 1
35
+ def perform(idx, ts = nil)
36
+ puts(Time.now.to_f - ts) if !ts.nil?
37
+ # raise idx.to_s if idx % 100 == 1
35
38
  end
36
39
  end
37
40
 
38
41
  # brew tap shopify/shopify
39
42
  # brew install toxiproxy
40
- # gem install toxiproxy
41
43
  # run `toxiproxy-server` in a separate terminal window.
42
- require 'toxiproxy'
44
+ require "toxiproxy"
43
45
  # simulate a non-localhost network for realer-world conditions.
44
46
  # adding 1ms of network latency has an ENORMOUS impact on benchmarks
45
47
  Toxiproxy.populate([{
46
- "name": "redis",
47
- "listen": "127.0.0.1:6380",
48
- "upstream": "127.0.0.1:6379"
48
+ name: "redis",
49
+ listen: "127.0.0.1:6380",
50
+ upstream: "127.0.0.1:6379"
49
51
  }])
50
52
 
51
53
  self_read, self_write = IO.pipe
52
- %w(INT TERM TSTP TTIN).each do |sig|
53
- begin
54
- trap sig do
55
- self_write.puts(sig)
56
- end
57
- rescue ArgumentError
58
- puts "Signal #{sig} not supported"
54
+ %w[INT TERM TSTP TTIN].each do |sig|
55
+ trap sig do
56
+ self_write.puts(sig)
59
57
  end
58
+ rescue ArgumentError
59
+ puts "Signal #{sig} not supported"
60
60
  end
61
61
 
62
- Sidekiq.redis {|c| c.flushdb}
62
+ Sidekiq.redis { |c| c.flushdb }
63
63
  def handle_signal(launcher, sig)
64
64
  Sidekiq.logger.debug "Got #{sig} signal"
65
65
  case sig
66
- when 'INT'
66
+ when "INT"
67
67
  # Handle Ctrl-C in JRuby like MRI
68
68
  # http://jira.codehaus.org/browse/JRUBY-4637
69
69
  raise Interrupt
70
- when 'TERM'
70
+ when "TERM"
71
71
  # Heroku sends TERM and then waits 30 seconds for process to exit.
72
72
  raise Interrupt
73
- when 'TSTP'
73
+ when "TSTP"
74
74
  Sidekiq.logger.info "Received TSTP, no longer accepting new work"
75
75
  launcher.quiet
76
- when 'TTIN'
76
+ when "TTIN"
77
77
  Thread.list.each do |thread|
78
- Sidekiq.logger.warn "Thread TID-#{(thread.object_id ^ ::Process.pid).to_s(36)} #{thread['label']}"
78
+ Sidekiq.logger.warn "Thread TID-#{(thread.object_id ^ ::Process.pid).to_s(36)} #{thread["label"]}"
79
79
  if thread.backtrace
80
80
  Sidekiq.logger.warn thread.backtrace.join("\n")
81
81
  else
@@ -89,52 +89,56 @@ def Process.rss
89
89
  `ps -o rss= -p #{Process.pid}`.chomp.to_i
90
90
  end
91
91
 
92
- iter = 10
92
+ iter = 50
93
93
  count = 10_000
94
94
 
95
95
  iter.times do
96
- arr = Array.new(count) do
97
- []
98
- end
99
- count.times do |idx|
100
- arr[idx][0] = idx
101
- end
102
- Sidekiq::Client.push_bulk('class' => LoadWorker, 'args' => arr)
96
+ arr = Array.new(count) { |idx| [idx] }
97
+ Sidekiq::Client.push_bulk("class" => LoadWorker, "args" => arr)
103
98
  end
104
- Sidekiq.logger.error "Created #{count*iter} jobs"
99
+ Sidekiq.logger.error "Created #{count * iter} jobs"
105
100
 
106
101
  start = Time.now
107
102
 
108
103
  Monitoring = Thread.new do
109
- watchdog("monitor thread") do
110
- while true
104
+ while true
105
+ sleep 0.2
106
+ qsize = Sidekiq.redis do |conn|
107
+ conn.llen "queue:default"
108
+ end
109
+ total = qsize
110
+ # Sidekiq.logger.error("RSS: #{Process.rss} Pending: #{total}")
111
+ if total == 0
112
+ Sidekiq.logger.error("Done, #{iter * count} jobs in #{Time.now - start} sec")
113
+ Sidekiq.logger.error("Now here's the latency for three jobs")
114
+
115
+ LoadWorker.perform_async(1, Time.now.to_f)
116
+ LoadWorker.perform_async(2, Time.now.to_f)
117
+ LoadWorker.perform_async(3, Time.now.to_f)
118
+
111
119
  sleep 0.2
112
- qsize = Sidekiq.redis do |conn|
113
- conn.llen "queue:default"
114
- end
115
- total = qsize
116
- #Sidekiq.logger.error("RSS: #{Process.rss} Pending: #{total}")
117
- if total == 0
118
- Sidekiq.logger.error("Done, #{iter * count} jobs in #{Time.now - start} sec")
119
- Sidekiq.logger.error("Now here's the latency for three jobs")
120
-
121
- LoadWorker.perform_async(1, Time.now.to_f)
122
- LoadWorker.perform_async(2, Time.now.to_f)
123
- LoadWorker.perform_async(3, Time.now.to_f)
124
-
125
- sleep 0.2
126
- exit(0)
127
- end
120
+ exit(0)
128
121
  end
129
122
  end
130
123
  end
131
124
 
125
+ def with_latency(latency, &block)
126
+ Sidekiq.logger.error "Simulating #{latency}ms of latency between Sidekiq and redis"
127
+ if latency > 0
128
+ Toxiproxy[:redis].downstream(:latency, latency: latency).apply(&block)
129
+ else
130
+ yield
131
+ end
132
+ end
133
+
132
134
  begin
133
- #RubyProf::exclude_threads = [ Monitoring ]
134
- #RubyProf.start
135
- fire_event(:startup)
136
- Sidekiq.logger.error "Simulating 1ms of latency between Sidekiq and redis"
137
- Toxiproxy[:redis].downstream(:latency, latency: 1).apply do
135
+ # RubyProf::exclude_threads = [ Monitoring ]
136
+ # RubyProf.start
137
+ events = Sidekiq.options[:lifecycle_events][:startup]
138
+ events.each(&:call)
139
+ events.clear
140
+
141
+ with_latency(Integer(ENV.fetch("LATENCY", "1"))) do
138
142
  launcher = Sidekiq::Launcher.new(Sidekiq.options)
139
143
  launcher.run
140
144
 
@@ -144,14 +148,14 @@ begin
144
148
  end
145
149
  end
146
150
  rescue SystemExit => e
147
- #Sidekiq.logger.error("Profiling...")
148
- #result = RubyProf.stop
149
- #printer = RubyProf::GraphHtmlPrinter.new(result)
150
- #printer.print(File.new("output.html", "w"), :min_percent => 1)
151
+ # Sidekiq.logger.error("Profiling...")
152
+ # result = RubyProf.stop
153
+ # printer = RubyProf::GraphHtmlPrinter.new(result)
154
+ # printer.print(File.new("output.html", "w"), :min_percent => 1)
151
155
  # normal
152
156
  rescue => e
153
157
  raise e if $DEBUG
154
- STDERR.puts e.message
155
- STDERR.puts e.backtrace.join("\n")
158
+ warn e.message
159
+ warn e.backtrace.join("\n")
156
160
  exit 1
157
161
  end
data/bin/sidekiqmon CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'sidekiq/monitor'
3
+ require "sidekiq/monitor"
4
4
 
5
5
  section = "all"
6
6
  section = ARGV[0] if ARGV.size == 1
data/lib/sidekiq/api.rb CHANGED
@@ -54,14 +54,14 @@ module Sidekiq
54
54
  # O(1) redis calls
55
55
  def fetch_stats_fast!
56
56
  pipe1_res = Sidekiq.redis { |conn|
57
- conn.pipelined do
58
- conn.get("stat:processed")
59
- conn.get("stat:failed")
60
- conn.zcard("schedule")
61
- conn.zcard("retry")
62
- conn.zcard("dead")
63
- conn.scard("processes")
64
- conn.lrange("queue:default", -1, -1)
57
+ conn.pipelined do |pipeline|
58
+ pipeline.get("stat:processed")
59
+ pipeline.get("stat:failed")
60
+ pipeline.zcard("schedule")
61
+ pipeline.zcard("retry")
62
+ pipeline.zcard("dead")
63
+ pipeline.scard("processes")
64
+ pipeline.lrange("queue:default", -1, -1)
65
65
  end
66
66
  }
67
67
 
@@ -101,9 +101,9 @@ module Sidekiq
101
101
  }
102
102
 
103
103
  pipe2_res = Sidekiq.redis { |conn|
104
- conn.pipelined do
105
- processes.each { |key| conn.hget(key, "busy") }
106
- queues.each { |queue| conn.llen("queue:#{queue}") }
104
+ conn.pipelined do |pipeline|
105
+ processes.each { |key| pipeline.hget(key, "busy") }
106
+ queues.each { |queue| pipeline.llen("queue:#{queue}") }
107
107
  end
108
108
  }
109
109
 
@@ -147,9 +147,9 @@ module Sidekiq
147
147
  Sidekiq.redis do |conn|
148
148
  queues = conn.sscan_each("queues").to_a
149
149
 
150
- lengths = conn.pipelined {
150
+ lengths = conn.pipelined { |pipeline|
151
151
  queues.each do |queue|
152
- conn.llen("queue:#{queue}")
152
+ pipeline.llen("queue:#{queue}")
153
153
  end
154
154
  }
155
155
 
@@ -191,7 +191,7 @@ module Sidekiq
191
191
  stat_hash[dates[idx]] = value ? value.to_i : 0
192
192
  end
193
193
  end
194
- rescue Redis::CommandError
194
+ rescue RedisConnection.adapter::CommandError
195
195
  # mget will trigger a CROSSSLOT error when run against a Cluster
196
196
  # TODO Someone want to add Cluster support?
197
197
  end
@@ -287,13 +287,17 @@ module Sidekiq
287
287
 
288
288
  def clear
289
289
  Sidekiq.redis do |conn|
290
- conn.multi do
291
- conn.unlink(@rname)
292
- conn.srem("queues", name)
290
+ conn.multi do |transaction|
291
+ transaction.unlink(@rname)
292
+ transaction.srem("queues", name)
293
293
  end
294
294
  end
295
295
  end
296
296
  alias_method :💣, :clear
297
+
298
+ def as_json(options = nil) # :nodoc:
299
+ {name: name} # 5336
300
+ end
297
301
  end
298
302
 
299
303
  ##
@@ -354,27 +358,31 @@ module Sidekiq
354
358
  def display_args
355
359
  # Unwrap known wrappers so they show up in a human-friendly manner in the Web UI
356
360
  @display_args ||= case klass
357
- when /\ASidekiq::Extensions::Delayed/
358
- safe_load(args[0], args) do |_, _, arg|
359
- arg
360
- end
361
- when "ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper"
362
- job_args = self["wrapped"] ? args[0]["arguments"] : []
363
- if (self["wrapped"] || args[0]) == "ActionMailer::DeliveryJob"
364
- # remove MailerClass, mailer_method and 'deliver_now'
365
- job_args.drop(3)
366
- elsif (self["wrapped"] || args[0]) == "ActionMailer::MailDeliveryJob"
367
- # remove MailerClass, mailer_method and 'deliver_now'
368
- job_args.drop(3).first["args"]
369
- else
370
- job_args
371
- end
372
- else
373
- if self["encrypt"]
374
- # no point in showing 150+ bytes of random garbage
375
- args[-1] = "[encrypted data]"
376
- end
377
- args
361
+ when /\ASidekiq::Extensions::Delayed/
362
+ safe_load(args[0], args) do |_, _, arg, kwarg|
363
+ if !kwarg || kwarg.empty?
364
+ arg
365
+ else
366
+ [arg, kwarg]
367
+ end
368
+ end
369
+ when "ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper"
370
+ job_args = self["wrapped"] ? args[0]["arguments"] : []
371
+ if (self["wrapped"] || args[0]) == "ActionMailer::DeliveryJob"
372
+ # remove MailerClass, mailer_method and 'deliver_now'
373
+ job_args.drop(3)
374
+ elsif (self["wrapped"] || args[0]) == "ActionMailer::MailDeliveryJob"
375
+ # remove MailerClass, mailer_method and 'deliver_now'
376
+ job_args.drop(3).first["args"]
377
+ else
378
+ job_args
379
+ end
380
+ else
381
+ if self["encrypt"]
382
+ # no point in showing 150+ bytes of random garbage
383
+ args[-1] = "[encrypted data]"
384
+ end
385
+ args
378
386
  end
379
387
  end
380
388
 
@@ -438,7 +446,8 @@ module Sidekiq
438
446
  rescue => ex
439
447
  # #1761 in dev mode, it's possible to have jobs enqueued which haven't been loaded into
440
448
  # memory yet so the YAML can't be loaded.
441
- Sidekiq.logger.warn "Unable to load YAML: #{ex.message}" unless Sidekiq.options[:environment] == "development"
449
+ # TODO is this still necessary? Zeitwerk reloader should handle?
450
+ Sidekiq.logger.warn "Unable to load YAML: #{ex.message}" unless Sidekiq.config[:environment] == "development"
442
451
  default
443
452
  end
444
453
 
@@ -466,7 +475,7 @@ module Sidekiq
466
475
 
467
476
  def initialize(parent, score, item)
468
477
  super(item)
469
- @score = score
478
+ @score = Float(score)
470
479
  @parent = parent
471
480
  end
472
481
 
@@ -519,9 +528,9 @@ module Sidekiq
519
528
 
520
529
  def remove_job
521
530
  Sidekiq.redis do |conn|
522
- results = conn.multi {
523
- conn.zrangebyscore(parent.name, score, score)
524
- conn.zremrangebyscore(parent.name, score, score)
531
+ results = conn.multi { |transaction|
532
+ transaction.zrangebyscore(parent.name, score, score)
533
+ transaction.zremrangebyscore(parent.name, score, score)
525
534
  }.first
526
535
 
527
536
  if results.size == 1
@@ -542,9 +551,9 @@ module Sidekiq
542
551
  yield msg if msg
543
552
 
544
553
  # push the rest back onto the sorted set
545
- conn.multi do
554
+ conn.multi do |transaction|
546
555
  nonmatched.each do |message|
547
- conn.zadd(parent.name, score.to_f.to_s, message)
556
+ transaction.zadd(parent.name, score.to_f.to_s, message)
548
557
  end
549
558
  end
550
559
  end
@@ -583,6 +592,10 @@ module Sidekiq
583
592
  end
584
593
  end
585
594
  alias_method :💣, :clear
595
+
596
+ def as_json(options = nil) # :nodoc:
597
+ {name: name} # 5336
598
+ end
586
599
  end
587
600
 
588
601
  class JobSet < SortedSet
@@ -602,7 +615,7 @@ module Sidekiq
602
615
  range_start = page * page_size + offset_size
603
616
  range_end = range_start + page_size - 1
604
617
  elements = Sidekiq.redis { |conn|
605
- conn.zrange name, range_start, range_end, with_scores: true
618
+ conn.zrange name, range_start, range_end, withscores: true
606
619
  }
607
620
  break if elements.empty?
608
621
  page -= 1
@@ -625,7 +638,7 @@ module Sidekiq
625
638
  end
626
639
 
627
640
  elements = Sidekiq.redis { |conn|
628
- conn.zrangebyscore(name, begin_score, end_score, with_scores: true)
641
+ conn.zrangebyscore(name, begin_score, end_score, withscores: true)
629
642
  }
630
643
 
631
644
  elements.each_with_object([]) do |element, result|
@@ -731,10 +744,10 @@ module Sidekiq
731
744
  def kill(message, opts = {})
732
745
  now = Time.now.to_f
733
746
  Sidekiq.redis do |conn|
734
- conn.multi do
735
- conn.zadd(name, now.to_s, message)
736
- conn.zremrangebyscore(name, "-inf", now - self.class.timeout)
737
- conn.zremrangebyrank(name, 0, - self.class.max_jobs)
747
+ conn.multi do |transaction|
748
+ transaction.zadd(name, now.to_s, message)
749
+ transaction.zremrangebyscore(name, "-inf", now - self.class.timeout)
750
+ transaction.zremrangebyrank(name, 0, - self.class.max_jobs)
738
751
  end
739
752
  end
740
753
 
@@ -754,11 +767,11 @@ module Sidekiq
754
767
  end
755
768
 
756
769
  def self.max_jobs
757
- Sidekiq.options[:dead_max_jobs]
770
+ Sidekiq[:dead_max_jobs]
758
771
  end
759
772
 
760
773
  def self.timeout
761
- Sidekiq.options[:dead_timeout_in_seconds]
774
+ Sidekiq[:dead_timeout_in_seconds]
762
775
  end
763
776
  end
764
777
 
@@ -782,9 +795,9 @@ module Sidekiq
782
795
  count = 0
783
796
  Sidekiq.redis do |conn|
784
797
  procs = conn.sscan_each("processes").to_a.sort
785
- heartbeats = conn.pipelined {
798
+ heartbeats = conn.pipelined { |pipeline|
786
799
  procs.each do |key|
787
- conn.hget(key, "info")
800
+ pipeline.hget(key, "info")
788
801
  end
789
802
  }
790
803
 
@@ -806,9 +819,9 @@ module Sidekiq
806
819
  # We're making a tradeoff here between consuming more memory instead of
807
820
  # making more roundtrips to Redis, but if you have hundreds or thousands of workers,
808
821
  # you'll be happier this way
809
- conn.pipelined do
822
+ conn.pipelined do |pipeline|
810
823
  procs.each do |key|
811
- conn.hmget(key, "info", "busy", "beat", "quiet", "rss", "rtt_us")
824
+ pipeline.hmget(key, "info", "busy", "beat", "quiet", "rss", "rtt_us")
812
825
  end
813
826
  end
814
827
  }
@@ -922,9 +935,9 @@ module Sidekiq
922
935
  def signal(sig)
923
936
  key = "#{identity}-signals"
924
937
  Sidekiq.redis do |c|
925
- c.multi do
926
- c.lpush(key, sig)
927
- c.expire(key, 60)
938
+ c.multi do |transaction|
939
+ transaction.lpush(key, sig)
940
+ transaction.expire(key, 60)
928
941
  end
929
942
  end
930
943
  end
@@ -958,9 +971,9 @@ module Sidekiq
958
971
  Sidekiq.redis do |conn|
959
972
  procs = conn.sscan_each("processes").to_a
960
973
  procs.sort.each do |key|
961
- valid, workers = conn.pipelined {
962
- conn.exists?(key)
963
- conn.hgetall("#{key}:workers")
974
+ valid, workers = conn.pipelined { |pipeline|
975
+ pipeline.exists?(key)
976
+ pipeline.hgetall("#{key}:work")
964
977
  }
965
978
  next unless valid
966
979
  workers.each_pair do |tid, json|
@@ -988,9 +1001,9 @@ module Sidekiq
988
1001
  if procs.empty?
989
1002
  0
990
1003
  else
991
- conn.pipelined {
1004
+ conn.pipelined { |pipeline|
992
1005
  procs.each do |key|
993
- conn.hget(key, "busy")
1006
+ pipeline.hget(key, "busy")
994
1007
  end
995
1008
  }.sum(&:to_i)
996
1009
  end