sidekiq 3.3.0 → 3.3.1

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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +7 -9
  3. data/Changes.md +16 -0
  4. data/Pro-2.0-Upgrade.md +102 -0
  5. data/Pro-Changes.md +14 -0
  6. data/README.md +3 -3
  7. data/Rakefile +0 -1
  8. data/bin/sidekiqctl +16 -14
  9. data/lib/sidekiq.rb +14 -14
  10. data/lib/sidekiq/api.rb +110 -40
  11. data/lib/sidekiq/cli.rb +11 -11
  12. data/lib/sidekiq/client.rb +13 -14
  13. data/lib/sidekiq/extensions/action_mailer.rb +5 -1
  14. data/lib/sidekiq/launcher.rb +4 -1
  15. data/lib/sidekiq/logging.rb +8 -7
  16. data/lib/sidekiq/manager.rb +9 -2
  17. data/lib/sidekiq/middleware/server/logging.rb +1 -1
  18. data/lib/sidekiq/middleware/server/retry_jobs.rb +4 -4
  19. data/lib/sidekiq/processor.rb +6 -6
  20. data/lib/sidekiq/testing.rb +8 -9
  21. data/lib/sidekiq/util.rb +8 -3
  22. data/lib/sidekiq/version.rb +1 -1
  23. data/lib/sidekiq/web.rb +33 -20
  24. data/lib/sidekiq/web_helpers.rb +13 -9
  25. data/lib/sidekiq/worker.rb +1 -2
  26. data/sidekiq.gemspec +1 -1
  27. data/test/test_api.rb +19 -10
  28. data/test/test_cli.rb +1 -1
  29. data/test/test_client.rb +1 -1
  30. data/test/test_exception_handler.rb +1 -1
  31. data/test/test_extensions.rb +1 -1
  32. data/test/test_fetch.rb +1 -1
  33. data/test/test_logging.rb +34 -0
  34. data/test/test_manager.rb +2 -2
  35. data/test/test_middleware.rb +1 -1
  36. data/test/test_processor.rb +1 -1
  37. data/test/test_redis_connection.rb +1 -1
  38. data/test/test_retry.rb +4 -2
  39. data/test/test_scheduled.rb +1 -1
  40. data/test/test_scheduling.rb +1 -1
  41. data/test/test_sidekiq.rb +13 -1
  42. data/test/test_testing.rb +1 -1
  43. data/test/test_testing_fake.rb +1 -1
  44. data/test/test_testing_inline.rb +1 -1
  45. data/test/test_web.rb +52 -9
  46. data/test/test_worker_generator.rb +1 -1
  47. data/web/assets/javascripts/locales/jquery.timeago.uz.js +0 -0
  48. data/web/assets/javascripts/locales/{jquery.timeago.zh-CN.js → jquery.timeago.zh-cn.js} +0 -0
  49. data/web/assets/javascripts/locales/{jquery.timeago.zh-TW.js → jquery.timeago.zh-tw.js} +0 -0
  50. data/web/assets/stylesheets/application.css +1 -4
  51. data/web/locales/ru.yml +6 -0
  52. data/web/views/_footer.erb +1 -1
  53. data/web/views/_summary.erb +1 -1
  54. data/web/views/busy.erb +3 -4
  55. data/web/views/dashboard.erb +1 -1
  56. metadata +10 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dea6136861d61b466dbeec68ffc57022140dddeb
4
- data.tar.gz: a8eae3c0c21c3006571739e68f5978bffd1312c6
3
+ metadata.gz: 5ebae4a31efb6367e41c8b9a808252448ed678bb
4
+ data.tar.gz: f32133f60e2b52b83653b83a0bb034a9fb649ec6
5
5
  SHA512:
6
- metadata.gz: a5c6decc852e45640a6b9526b38f1457fb75fe5fb439f53f0d30b8108f50c4817e20398833188ebfdbabc0f88e15f362654256f1ef3457f7ac2554ce083ff87a
7
- data.tar.gz: 692dbde9798b2bca0d0db7c62cd47912ba43e6422ba2d159009715a904c9ca277875d69b7271aeefbc01be4f3c23e7a2ca7098a76843c97b027a31d46a34300b
6
+ metadata.gz: d439e1b3ac4a44c5f9d59a91289041241eb66659952b80cf10f1bce3c5a32b3d7972821e62430a21ab4a4ec20fdf0a6546dbbe5a127437a24e24355381cc6f39
7
+ data.tar.gz: 4d199feb0af0d1c099f137f743b38ec56cd98110d10a1b8d2bad4dc6cbdc7afe1057a368ef7079eb92582edb9518a3584e4e1436a420419a1150a3b6510a1bf8
@@ -1,18 +1,16 @@
1
1
  language: ruby
2
+ sudo: false
3
+ cache: bundler
2
4
  services:
3
5
  - redis-server
4
6
  rvm:
5
- - jruby-19mode
6
- - rbx-2
7
- - 2.0.0
8
7
  - 2.1
8
+ - 2.0.0
9
9
  - 2.2
10
+ - jruby-19mode
11
+ - jruby
12
+ - rbx-2
10
13
  matrix:
11
- global:
12
- - BUNDLE_JOBS=4
13
14
  allow_failures:
14
15
  - rvm: rbx-2
15
- before_install:
16
- # Only use 1 job until Travis fixes the rbx --jobs issue.
17
- - if [ "$TRAVIS_RUBY_VERSION" == "rbx-2" ] ; then export BUNDLE_JOBS=1 ; fi
18
- install: bundle install --retry=3
16
+ - rvm: jruby
data/Changes.md CHANGED
@@ -1,3 +1,19 @@
1
+ 3.3.1
2
+ -----------
3
+
4
+ - Dumb down ActionMailer integration so it tries to deliver if possible [#2149]
5
+ - Stringify Sidekiq.default_worker_options's keys [#2126]
6
+ - Add random integer to process identity [#2113, michaeldiscala]
7
+ - Log Sidekiq Pro's Batch ID if available [#2076]
8
+ - Refactor Processor Redis usage to avoid redis/redis-rb#490 [#2094]
9
+ - Move /dashboard/stats to /stats. Add /stats/queues. [moserke, #2099]
10
+ - Add processes count to /stats [ismaelga, #2141]
11
+ - Greatly improve speed of Sidekiq::Stats [ismaelga, #2142]
12
+ - Add better usage text for `sidekiqctl`.
13
+ - `Sidekiq::Logging.with_context` is now a stack so you can set your
14
+ own job context for logging purposes [grosser, #2110]
15
+ - Remove usage of Google Fonts in Web UI so it loads in China [#2144]
16
+
1
17
  3.3.0
2
18
  -----------
3
19
 
@@ -0,0 +1,102 @@
1
+ # Upgrading to Sidekiq Pro 2.0
2
+
3
+ Sidekiq Pro 2.0 allows nested batches for more complex job workflows.
4
+ It also removes deprecated APIs, changes the batch data format and
5
+ how features are activated. Read carefully to ensure your upgrade goes
6
+ smoothly.
7
+
8
+ ## Nested Batches
9
+
10
+ Batches can now be nested within the `jobs` method.
11
+ This feature enables Sidekiq Pro to handle workflow processing of any size
12
+ and complexity!
13
+
14
+ ```ruby
15
+ a = Sidekiq::Batch.new
16
+ a.on(:success, SomeCallback)
17
+ a.jobs do
18
+ SomeWork.perform_async
19
+
20
+ b = Sidekiq::Batch.new
21
+ b.on(:success, MyCallback)
22
+ b.jobs do
23
+ OtherWork.perform_async
24
+ end
25
+ end
26
+ ```
27
+
28
+ Parent batch callbacks are not processed until any child batch callbacks have
29
+ run successfully. In the example above, `MyCallback` will always fire
30
+ before `SomeCallback` because `b` is considered a child of `a`.
31
+
32
+ Of course you can dynamically add child batches while a batch job is executing.
33
+
34
+ ```ruby
35
+ def perform(*args)
36
+ do_something(args)
37
+
38
+ if more_work?
39
+ # Sidekiq::Worker#batch returns the Batch this job is part of.
40
+ batch.jobs do
41
+ b = Sidekiq::Batch.new
42
+ b.on(:success, MyCallback)
43
+ b.jobs do
44
+ OtherWork.perform_async
45
+ end
46
+ end
47
+ end
48
+ end
49
+ ```
50
+
51
+ ## Batch Data
52
+
53
+ The batch data model was overhauled. Batch data should take
54
+ significantly less space in Redis now. A simple benchmark shows 25%
55
+ savings but real world savings should be even greater.
56
+
57
+ * Batch 2.x BIDs are 14 character URL-safe Base64-encoded strings, e.g.
58
+ "vTF1-9QvLPnREQ". Batch 1.x BIDs were 16 character hex-encoded
59
+ strings, e.g. "4a3fc67d30370edf".
60
+ * In 1.x, batch data was not removed until it naturally expired in Redis.
61
+ In 2.x, all data for a batch is removed from Redis once the batch has
62
+ run any success callbacks.
63
+ * Because of the former point, batch expiry is no longer a concern.
64
+ Batch expiry is hardcoded to 30 days and is no longer user-tunable.
65
+ * Failed batch jobs no longer automatically store any associated
66
+ backtrace in Redis.
67
+
68
+ **There's no data migration required. Sidekiq Pro 2.0 transparently handles
69
+ both old and new format.**
70
+
71
+ **Note that you CANNOT go back to Pro 1.x once you've created batches
72
+ with 2.x. The new batches will not process correctly with 1.x.**
73
+
74
+ ## Reliability
75
+
76
+ You no longer need to require anything to use Reliability features.
77
+
78
+ * Activate reliable fetch:
79
+ ```ruby
80
+ Sidekiq.configure_server do |config|
81
+ config.reliable_fetch!
82
+ end
83
+ ```
84
+ * Activate reliable push:
85
+ ```ruby
86
+ Sidekiq::Client.reliable_push!
87
+ ```
88
+
89
+ ## Other Changes
90
+
91
+ * You must require `sidekiq/notifications` if you want to use the
92
+ existing notification schemes. I don't recommend using them as the
93
+ newer-style `Sidekiq::Batch#on` method is simpler and more flexible.
94
+ * Several classes have been renamed. Generally these classes are ones
95
+ you should not need to require/use in your own code, e.g. the Batch
96
+ middleware.
97
+ * The Web UI now shows the Sidekiq Pro version in the footer.
98
+
99
+ ## Thanks
100
+
101
+ Adam Prescott, Luke van der Hoeven and Jon Hyman all provided valuable
102
+ feedback during the release process. Thank you guys!
@@ -3,6 +3,20 @@ Sidekiq Pro Changelog
3
3
 
4
4
  Please see [http://sidekiq.org/pro](http://sidekiq.org/pro) for more details and how to buy.
5
5
 
6
+
7
+ 2.0.0 (see mperham/sidekiq#2130 for progress)
8
+ -----------
9
+
10
+ - See [[Pro-2.0-Upgrade.md]] for thorough release notes.
11
+
12
+ 1.9.2
13
+ -----------
14
+
15
+ - As of 1/1/2015, Sidekiq Pro is hosted on a new dedicated server.
16
+ Happy new year and let's hope for 100% uptime!
17
+ - Fix bug in reliable\_fetch where jobs could be duplicated if a Sidekiq
18
+ process crashed and you were using weighted queues. [#2120]
19
+
6
20
  1.9.1
7
21
  -----------
8
22
 
data/README.md CHANGED
@@ -24,7 +24,7 @@ the same CPU and perform the same amount of work.
24
24
  Requirements
25
25
  -----------------
26
26
 
27
- I test with the latest MRI (2.1, 2.0) and JRuby versions (1.7). Other versions/VMs
27
+ I test with the latest MRI (2.2, 2.1 and 2.0) and JRuby versions (1.7). Other versions/VMs
28
28
  are untested but might work fine. MRI 1.9 is no longer supported.
29
29
 
30
30
  All Rails releases starting from 3.2 are officially supported.
@@ -41,7 +41,7 @@ Installation
41
41
  Getting Started
42
42
  -----------------
43
43
 
44
- See the [sidekiq home page](http://mperham.github.com/sidekiq) for the simple 3-step process.
44
+ See the [sidekiq home page](http://sidekiq.org) for the simple 3-step process.
45
45
  You can watch [Railscast #366](http://railscasts.com/episodes/366-sidekiq) to see Sidekiq in action. If you do everything right, you should see this:
46
46
 
47
47
  ![Web UI](https://github.com/mperham/sidekiq/raw/master/examples/web-ui.png)
@@ -91,4 +91,4 @@ Please see [LICENSE](https://github.com/mperham/sidekiq/blob/master/LICENSE) for
91
91
  Author
92
92
  -----------------
93
93
 
94
- Mike Perham, [@mperham](https://twitter.com/mperham) / [@sidekiq](https://twitter.com/sidekiq), [http://mikeperham.com](http://mikeperham.com) / [http://www.contribsys.com](http://www.contribsys.com)
94
+ Mike Perham, [@mperham](https://twitter.com/mperham) / [@sidekiq](https://twitter.com/sidekiq), [http://www.mikeperham.com](http://www.mikeperham.com) / [http://www.contribsys.com](http://www.contribsys.com)
data/Rakefile CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
3
  Rake::TestTask.new(:test) do |test|
4
- test.libs << 'test'
5
4
  #SO MUCH NOISE
6
5
  #test.warning = true
7
6
  test.pattern = 'test/**/test_*.rb'
@@ -3,23 +3,29 @@
3
3
  require 'fileutils'
4
4
 
5
5
  class Sidekiqctl
6
- DEFAULT_TIMEOUT = 10
6
+ DEFAULT_KILL_TIMEOUT = 10
7
7
 
8
- attr_reader :stage, :pidfile, :timeout
8
+ attr_reader :stage, :pidfile, :kill_timeout
9
9
 
10
10
  def self.print_usage
11
+ puts "#{File.basename($0)} - stop a Sidekiq process from the command line."
11
12
  puts
12
- puts "Usage: #{File.basename($0)} <command> <pidfile> <timeout>"
13
- puts " where <command> is either 'quiet', 'stop' or 'shutdown'"
13
+ puts "Usage: #{File.basename($0)} <command> <pidfile> <kill_timeout>"
14
+ puts " where <command> is either 'quiet' or 'stop'"
14
15
  puts " <pidfile> is path to a pidfile"
15
- puts " <timeout> is number of seconds to wait till Sidekiq exits (default: #{Sidekiqctl::DEFAULT_TIMEOUT})"
16
+ puts " <kill_timeout> is number of seconds to wait until Sidekiq exits"
17
+ puts " (default: #{Sidekiqctl::DEFAULT_KILL_TIMEOUT}), after which Sidekiq will be KILL'd"
18
+ puts
19
+ puts "Be sure to set the kill_timeout LONGER than Sidekiq's -t timeout. If you want"
20
+ puts "to wait 60 seconds for jobs to finish, use `sidekiq -t 60` and `sidekiqctl stop"
21
+ puts " path_to_pidfile 61`"
16
22
  puts
17
23
  end
18
24
 
19
25
  def initialize(stage, pidfile, timeout)
20
26
  @stage = stage
21
27
  @pidfile = pidfile
22
- @timeout = timeout
28
+ @kill_timeout = timeout
23
29
 
24
30
  done('No pidfile given', :error) if !pidfile
25
31
  done("Pidfile #{pidfile} does not exist", :warn) if !File.exist?(pidfile)
@@ -30,7 +36,7 @@ class Sidekiqctl
30
36
  begin
31
37
  send(stage)
32
38
  rescue NoMethodError
33
- done 'Invalid control command', :error
39
+ done "Invalid command: #{stage}", :error
34
40
  end
35
41
  end
36
42
 
@@ -59,7 +65,7 @@ class Sidekiqctl
59
65
 
60
66
  def stop
61
67
  `kill -TERM #{pid}`
62
- timeout.times do
68
+ kill_timeout.times do
63
69
  begin
64
70
  Process.getpgid(pid)
65
71
  rescue Errno::ESRCH
@@ -72,11 +78,7 @@ class Sidekiqctl
72
78
  FileUtils.rm_f pidfile
73
79
  done 'Sidekiq shut down forcefully.'
74
80
  end
75
-
76
- def shutdown
77
- quiet
78
- stop
79
- end
81
+ alias_method :shutdown, :stop
80
82
  end
81
83
 
82
84
  if ARGV.length < 2
@@ -85,7 +87,7 @@ else
85
87
  stage = ARGV[0]
86
88
  pidfile = ARGV[1]
87
89
  timeout = ARGV[2].to_i
88
- timeout = Sidekiqctl::DEFAULT_TIMEOUT if timeout == 0
90
+ timeout = Sidekiqctl::DEFAULT_KILL_TIMEOUT if timeout == 0
89
91
 
90
92
  Sidekiqctl.new(stage, pidfile, timeout)
91
93
  end
@@ -10,21 +10,21 @@ require 'sidekiq/redis_connection'
10
10
  require 'json'
11
11
 
12
12
  module Sidekiq
13
- NAME = "Sidekiq"
13
+ NAME = 'Sidekiq'
14
14
  LICENSE = 'See LICENSE and the LGPL-3.0 for licensing details.'
15
15
 
16
16
  DEFAULTS = {
17
- :queues => [],
18
- :labels => [],
19
- :concurrency => 25,
20
- :require => '.',
21
- :environment => nil,
22
- :timeout => 8,
23
- :error_handlers => [],
24
- :lifecycle_events => {
25
- :startup => [],
26
- :quiet => [],
27
- :shutdown => [],
17
+ queues: [],
18
+ labels: [],
19
+ concurrency: 25,
20
+ require: '.',
21
+ environment: nil,
22
+ timeout: 8,
23
+ error_handlers: [],
24
+ lifecycle_events: {
25
+ startup: [],
26
+ quiet: [],
27
+ shutdown: [],
28
28
  }
29
29
  }
30
30
 
@@ -97,7 +97,7 @@ module Sidekiq
97
97
  end
98
98
 
99
99
  def self.default_worker_options=(hash)
100
- @default_worker_options = default_worker_options.merge(hash)
100
+ @default_worker_options = default_worker_options.merge(hash.stringify_keys)
101
101
  end
102
102
 
103
103
  def self.default_worker_options
@@ -146,7 +146,7 @@ module Sidekiq
146
146
  # end
147
147
  def self.on(event, &block)
148
148
  raise ArgumentError, "Symbols only please: #{event}" unless event.is_a?(Symbol)
149
- raise ArgumentError, "Invalid event name: #{event}" unless options[:lifecycle_events].keys.include?(event)
149
+ raise ArgumentError, "Invalid event name: #{event}" unless options[:lifecycle_events].key?(event)
150
150
  options[:lifecycle_events][event] << block
151
151
  end
152
152
  end
@@ -3,12 +3,89 @@ require 'sidekiq'
3
3
 
4
4
  module Sidekiq
5
5
  class Stats
6
+ def initialize
7
+ fetch_stats!
8
+ end
9
+
6
10
  def processed
7
- Sidekiq.redis { |conn| conn.get("stat:processed") }.to_i
11
+ stat :processed
8
12
  end
9
13
 
10
14
  def failed
11
- Sidekiq.redis { |conn| conn.get("stat:failed") }.to_i
15
+ stat :failed
16
+ end
17
+
18
+ def scheduled_size
19
+ stat :scheduled_size
20
+ end
21
+
22
+ def retry_size
23
+ stat :retry_size
24
+ end
25
+
26
+ def dead_size
27
+ stat :dead_size
28
+ end
29
+
30
+ def enqueued
31
+ stat :enqueued
32
+ end
33
+
34
+ def processes_size
35
+ stat :processes_size
36
+ end
37
+
38
+ def workers_size
39
+ stat :workers_size
40
+ end
41
+
42
+ def default_queue_latency
43
+ stat :default_queue_latency
44
+ end
45
+
46
+ def fetch_stats!
47
+ pipe1_res = Sidekiq.redis do |conn|
48
+ conn.pipelined do
49
+ conn.get('stat:processed'.freeze)
50
+ conn.get('stat:failed'.freeze)
51
+ conn.zcard('schedule'.freeze)
52
+ conn.zcard('retry'.freeze)
53
+ conn.zcard('dead'.freeze)
54
+ conn.scard('processes'.freeze)
55
+ conn.lrange('queue:default'.freeze, -1, -1)
56
+ conn.smembers('processes'.freeze)
57
+ conn.smembers('queues'.freeze)
58
+ end
59
+ end
60
+
61
+ pipe2_res = Sidekiq.redis do |conn|
62
+ conn.pipelined do
63
+ pipe1_res[7].each {|key| conn.hget(key, 'busy'.freeze) }
64
+ pipe1_res[8].each {|queue| conn.llen("queue:#{queue}") }
65
+ end
66
+ end
67
+
68
+ s = pipe1_res[7].size
69
+ workers_size = pipe2_res[0...s].map(&:to_i).inject(0, &:+)
70
+ enqueued = pipe2_res[s..-1].map(&:to_i).inject(0, &:+)
71
+
72
+ default_queue_latency = if (entry = pipe1_res[6].first)
73
+ Time.now.to_f - Sidekiq.load_json(entry)['enqueued_at'.freeze]
74
+ else
75
+ 0
76
+ end
77
+ @stats = {
78
+ processed: pipe1_res[0].to_i,
79
+ failed: pipe1_res[1].to_i,
80
+ scheduled_size: pipe1_res[2],
81
+ retry_size: pipe1_res[3],
82
+ dead_size: pipe1_res[4],
83
+ processes_size: pipe1_res[5],
84
+
85
+ default_queue_latency: default_queue_latency,
86
+ workers_size: workers_size,
87
+ enqueued: enqueued
88
+ }
12
89
  end
13
90
 
14
91
  def reset(*stats)
@@ -25,41 +102,33 @@ module Sidekiq
25
102
  end
26
103
  end
27
104
 
28
- def queues
29
- Sidekiq.redis do |conn|
30
- queues = conn.smembers('queues')
31
-
32
- lengths = conn.pipelined do
33
- queues.each do |queue|
34
- conn.llen("queue:#{queue}")
35
- end
36
- end
37
-
38
- i = 0
39
- array_of_arrays = queues.inject({}) do |memo, queue|
40
- memo[queue] = lengths[i]
41
- i += 1
42
- memo
43
- end.sort_by { |_, size| size }
105
+ private
44
106
 
45
- Hash[array_of_arrays.reverse]
46
- end
107
+ def stat(s)
108
+ @stats[s]
47
109
  end
48
110
 
49
- def enqueued
50
- queues.values.inject(&:+) || 0
51
- end
111
+ class Queues
112
+ def lengths
113
+ Sidekiq.redis do |conn|
114
+ queues = conn.smembers('queues'.freeze)
52
115
 
53
- def scheduled_size
54
- Sidekiq.redis {|c| c.zcard('schedule') }
55
- end
116
+ lengths = conn.pipelined do
117
+ queues.each do |queue|
118
+ conn.llen("queue:#{queue}")
119
+ end
120
+ end
56
121
 
57
- def retry_size
58
- Sidekiq.redis {|c| c.zcard('retry') }
59
- end
122
+ i = 0
123
+ array_of_arrays = queues.inject({}) do |memo, queue|
124
+ memo[queue] = lengths[i]
125
+ i += 1
126
+ memo
127
+ end.sort_by { |_, size| size }
60
128
 
61
- def dead_size
62
- Sidekiq.redis {|c| c.zcard('dead') }
129
+ Hash[array_of_arrays.reverse]
130
+ end
131
+ end
63
132
  end
64
133
 
65
134
  class History
@@ -92,8 +161,8 @@ module Sidekiq
92
161
  end
93
162
 
94
163
  Sidekiq.redis do |conn|
95
- conn.mget(keys).each_with_index do |value, i|
96
- stat_hash[dates[i].to_s] = value ? value.to_i : 0
164
+ conn.mget(keys).each_with_index do |value, idx|
165
+ stat_hash[dates[idx].to_s] = value ? value.to_i : 0
97
166
  end
98
167
  end
99
168
 
@@ -118,7 +187,7 @@ module Sidekiq
118
187
  include Enumerable
119
188
 
120
189
  def self.all
121
- Sidekiq.redis {|c| c.smembers('queues') }.sort.map {|q| Sidekiq::Queue.new(q) }
190
+ Sidekiq.redis {|c| c.smembers('queues'.freeze) }.sort.map {|q| Sidekiq::Queue.new(q) }
122
191
  end
123
192
 
124
193
  attr_reader :name
@@ -174,7 +243,7 @@ module Sidekiq
174
243
  Sidekiq.redis do |conn|
175
244
  conn.multi do
176
245
  conn.del(@rname)
177
- conn.srem("queues", name)
246
+ conn.srem("queues".freeze, name)
178
247
  end
179
248
  end
180
249
  end
@@ -267,7 +336,7 @@ module Sidekiq
267
336
 
268
337
  def safe_load(content, default)
269
338
  begin
270
- yield *YAML.load(content)
339
+ yield(*YAML.load(content))
271
340
  rescue ::ArgumentError => ex
272
341
  # #1761 in dev mode, it's possible to have jobs enqueued which haven't been loaded into
273
342
  # memory yet so the YAML can't be loaded.
@@ -382,7 +451,7 @@ module Sidekiq
382
451
  end
383
452
 
384
453
  def size
385
- Sidekiq.redis {|c| c.zcard(name) }
454
+ Sidekiq.redis { |c| c.zcard(name) }
386
455
  end
387
456
 
388
457
  def clear
@@ -411,7 +480,7 @@ module Sidekiq
411
480
  range_start = page * page_size + offset_size
412
481
  range_end = page * page_size + offset_size + (page_size - 1)
413
482
  elements = Sidekiq.redis do |conn|
414
- conn.zrange name, range_start, range_end, :with_scores => true
483
+ conn.zrange name, range_start, range_end, with_scores: true
415
484
  end
416
485
  break if elements.empty?
417
486
  page -= 1
@@ -586,7 +655,7 @@ module Sidekiq
586
655
  end
587
656
  end
588
657
 
589
- result.each_with_index do |(info, busy, at_s), i|
658
+ result.each do |info, busy, at_s|
590
659
  hash = Sidekiq.load_json(info)
591
660
  yield Process.new(hash.merge('busy' => busy.to_i, 'beat' => at_s.to_f))
592
661
  end
@@ -616,6 +685,7 @@ module Sidekiq
616
685
  # 'queues' => ['default', 'low'],
617
686
  # 'busy' => 10,
618
687
  # 'beat' => <last heartbeat>,
688
+ # 'identity' => <unique string identifying the process>,
619
689
  # }
620
690
  class Process
621
691
  def initialize(hash)
@@ -655,7 +725,7 @@ module Sidekiq
655
725
  end
656
726
 
657
727
  def identity
658
- @id ||= "#{self['hostname']}:#{self['pid']}"
728
+ self['identity']
659
729
  end
660
730
  end
661
731