sidekiq 6.0.0 → 6.0.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.
- checksums.yaml +4 -4
- data/.circleci/config.yml +21 -0
- data/6.0-Upgrade.md +3 -1
- data/Changes.md +76 -1
- data/Ent-Changes.md +6 -0
- data/Gemfile.lock +3 -3
- data/Pro-Changes.md +9 -1
- data/README.md +1 -0
- data/bin/sidekiqload +8 -4
- data/bin/sidekiqmon +4 -5
- data/lib/generators/sidekiq/worker_generator.rb +10 -0
- data/lib/sidekiq.rb +8 -0
- data/lib/sidekiq/api.rb +74 -40
- data/lib/sidekiq/cli.rb +16 -16
- data/lib/sidekiq/client.rb +8 -2
- data/lib/sidekiq/fetch.rb +7 -7
- data/lib/sidekiq/job_logger.rb +11 -3
- data/lib/sidekiq/job_retry.rb +17 -6
- data/lib/sidekiq/launcher.rb +1 -3
- data/lib/sidekiq/logger.rb +107 -11
- data/lib/sidekiq/middleware/chain.rb +11 -2
- data/lib/sidekiq/monitor.rb +2 -2
- data/lib/sidekiq/paginator.rb +7 -2
- data/lib/sidekiq/processor.rb +31 -11
- data/lib/sidekiq/scheduled.rb +13 -12
- data/lib/sidekiq/testing.rb +12 -0
- data/lib/sidekiq/version.rb +1 -1
- data/lib/sidekiq/web/application.rb +7 -11
- data/lib/sidekiq/web/helpers.rb +22 -4
- data/lib/sidekiq/worker.rb +4 -4
- data/sidekiq.gemspec +1 -1
- data/web/assets/javascripts/dashboard.js +2 -2
- data/web/assets/stylesheets/application-dark.css +125 -0
- data/web/assets/stylesheets/application.css +9 -0
- data/web/views/_job_info.erb +2 -1
- data/web/views/busy.erb +4 -1
- data/web/views/dead.erb +2 -2
- data/web/views/layout.erb +1 -0
- data/web/views/morgue.erb +4 -1
- data/web/views/queue.erb +10 -1
- data/web/views/retries.erb +4 -1
- data/web/views/retry.erb +2 -2
- data/web/views/scheduled.erb +4 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 792692164ce00b070d352bda8869518e3d20d92cfdb70cda88456b53d5a4a627
|
4
|
+
data.tar.gz: b489c2ecc7b3708dd578a0184a9da58ac32d36e737a3b704d094e1ef375e93e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80d7bd6a6fc9ef0a6026c9c5bb8aaf727db7323e1f1d9e057550681329991ddf82de030df70dc80e8f3a3608fc1f999ecb5d251765a5bcf09f23f764d86365a7
|
7
|
+
data.tar.gz: 3148011168f88fbc4fa67f244a56be0b0e7da36d5009f4d465e0df2a7df93ddf8a99fc1c57c43fa0365a0cdb1de9fb770306daf070bcea5f330c1f3522210bf9
|
data/.circleci/config.yml
CHANGED
@@ -32,6 +32,9 @@ jobs:
|
|
32
32
|
- <<: *save
|
33
33
|
- <<: *unit
|
34
34
|
"ruby-2.6":
|
35
|
+
environment:
|
36
|
+
COVERAGE: true
|
37
|
+
CC_TEST_REPORTER_ID: 003c3033501d70a2653bd887ff9a8b2884a263e6a4e27f2ba68748e15530918d
|
35
38
|
docker:
|
36
39
|
- image: circleci/ruby:2.6
|
37
40
|
- image: circleci/redis:4.0
|
@@ -40,7 +43,25 @@ jobs:
|
|
40
43
|
- <<: *restore
|
41
44
|
- <<: *bundle
|
42
45
|
- <<: *save
|
46
|
+
|
47
|
+
- run:
|
48
|
+
name: Setup Code Climate test-reporter
|
49
|
+
command: |
|
50
|
+
# download test reporter as a static binary
|
51
|
+
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
52
|
+
chmod +x ./cc-test-reporter
|
53
|
+
|
54
|
+
- run:
|
55
|
+
name: Code Climate before-build
|
56
|
+
command: |
|
57
|
+
./cc-test-reporter before-build
|
58
|
+
|
43
59
|
- <<: *unit
|
60
|
+
|
61
|
+
- run:
|
62
|
+
name: Report code coverage to Code Climate
|
63
|
+
command: |
|
64
|
+
./cc-test-reporter after-build -t simplecov --exit-code $?
|
44
65
|
"jruby":
|
45
66
|
docker:
|
46
67
|
- image: circleci/jruby:latest
|
data/6.0-Upgrade.md
CHANGED
@@ -10,6 +10,7 @@ This release has major breaking changes. Read and test carefully in production.
|
|
10
10
|
- ActiveJobs can now use `sidekiq_options` directly to configure Sidekiq
|
11
11
|
features/internals like the retry subsystem. Prefer the native
|
12
12
|
Sidekiq::Worker APIs as some Sidekiq features (e.g. unique jobs) do not work well with AJ.
|
13
|
+
(requires Rails 6.0.1)
|
13
14
|
```ruby
|
14
15
|
class MyJob < ActiveJob::Base
|
15
16
|
queue_as :myqueue
|
@@ -31,9 +32,10 @@ you can override it by configuring the log formatter explicitly. See
|
|
31
32
|
```ruby
|
32
33
|
Sidekiq.configure_server do |config|
|
33
34
|
config.log_formatter = AcmeCorp::PlainLogFormatter.new
|
34
|
-
# config.log_formatter = Sidekiq::Logger::
|
35
|
+
# config.log_formatter = Sidekiq::Logger::Formatters::JSON.new
|
35
36
|
end
|
36
37
|
```
|
38
|
+
Please see the [Logging](https://github.com/mperham/sidekiq/wiki/Logging) wiki page for the latest documentation and notes.
|
37
39
|
- **Remove the daemonization, logfile and pidfile command line arguments and `sidekiqctl` binary**.
|
38
40
|
I've [noted for years](https://www.mikeperham.com/2014/09/22/dont-daemonize-your-daemons/)
|
39
41
|
how modern services should be managed with a proper init system.
|
data/Changes.md
CHANGED
@@ -2,12 +2,80 @@
|
|
2
2
|
|
3
3
|
[Sidekiq Changes](https://github.com/mperham/sidekiq/blob/master/Changes.md) | [Sidekiq Pro Changes](https://github.com/mperham/sidekiq/blob/master/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/mperham/sidekiq/blob/master/Ent-Changes.md)
|
4
4
|
|
5
|
+
HEAD
|
6
|
+
---------
|
7
|
+
|
8
|
+
- **Performance tuning**, Sidekiq should be 10-15% faster now [#4303, 4299,
|
9
|
+
4269, fatkodima]
|
10
|
+
- **Dark Mode support in Web UI** (further design polish welcome!) [#4227, mperham,
|
11
|
+
fatkodima, silent-e]
|
12
|
+
- **Job-specific log levels**, allowing you to turn on debugging for
|
13
|
+
problematic workers. [fatkodima, #4287]
|
14
|
+
```ruby
|
15
|
+
MyWorker.set(log_level: :debug).perform_async(...)
|
16
|
+
```
|
17
|
+
- **Ad-hoc job tags**. You can tag your jobs with, e.g, subdomain, tenant, country,
|
18
|
+
locale, application, version, user/client, "alpha/beta/pro/ent", types of jobs,
|
19
|
+
teams/people responsible for jobs, additional metadata, etc.
|
20
|
+
Tags are shown on different pages with job listings. Sidekiq Pro users
|
21
|
+
can filter based on them [fatkodima, #4280]
|
22
|
+
```ruby
|
23
|
+
class MyWorker
|
24
|
+
include Sidekiq::Worker
|
25
|
+
sidekiq_options tags: ['bank-ops', 'alpha']
|
26
|
+
...
|
27
|
+
end
|
28
|
+
```
|
29
|
+
- Fetch scheduled jobs in batches before pushing into specific queues.
|
30
|
+
This will decrease enqueueing time of scheduled jobs by a third. [fatkodima, #4273]
|
31
|
+
```
|
32
|
+
ScheduledSet with 10,000 jobs
|
33
|
+
Before: 56.6 seconds
|
34
|
+
After: 39.2 seconds
|
35
|
+
```
|
36
|
+
- Compress error backtraces before pushing into Redis, if you are
|
37
|
+
storing error backtraces, this will halve the size of your RetrySet
|
38
|
+
in Redis [fatkodima, #4272]
|
39
|
+
```
|
40
|
+
RetrySet with 100,000 jobs
|
41
|
+
Before: 261 MB
|
42
|
+
After: 129 MB
|
43
|
+
```
|
44
|
+
- Support display of ActiveJob 6.0 payloads in the Web UI [#4263]
|
45
|
+
- Add `SortedSet#scan` for pattern based scanning. For large sets this API will be **MUCH** faster
|
46
|
+
than standard iteration using each. [fatkodima, #4262]
|
47
|
+
```ruby
|
48
|
+
Sidekiq::DeadSet.new.scan("UnreliableApi") do |job|
|
49
|
+
job.retry
|
50
|
+
end
|
51
|
+
```
|
52
|
+
- Dramatically speed up SortedSet#find\_job(jid) by using Redis's ZSCAN
|
53
|
+
support, approx 10x faster. [fatkodima, #4259]
|
54
|
+
```
|
55
|
+
zscan 0.179366 0.047727 0.227093 ( 1.161376)
|
56
|
+
enum 8.522311 0.419826 8.942137 ( 9.785079)
|
57
|
+
```
|
58
|
+
- Respect rails' generators `test_framework` option and gracefully handle extra `worker` suffix on generator [fatkodima, #4256]
|
59
|
+
- Add ability to sort 'Enqueued' page on Web UI by position in the queue [fatkodima, #4248]
|
60
|
+
- Support `Client.push_bulk` with different delays [fatkodima, #4243]
|
61
|
+
```ruby
|
62
|
+
Sidekiq::Client.push_bulk("class" => FooJob, "args" => [[1], [2]], "at" => [1.minute.from_now.to_f, 5.minutes.from_now.to_f])
|
63
|
+
```
|
64
|
+
- Easier way to test enqueuing specific ActionMailer and ActiveRecord delayed jobs. Instead of manually
|
65
|
+
parsing embedded class, you can now test by fetching jobs for specific classes. [fatkodima, #4292]
|
66
|
+
```ruby
|
67
|
+
assert_equal 1, Sidekiq::Extensions::DelayedMailer.jobs_for(FooMailer).size
|
68
|
+
```
|
69
|
+
- Add `sidekiqmon` to gemspec executables [#4242]
|
70
|
+
- Gracefully handle `Sidekiq.logger = nil` [#4240]
|
71
|
+
- Inject Sidekiq::LogContext module if user-supplied logger does not include it [#4239]
|
72
|
+
|
5
73
|
6.0
|
6
74
|
---------
|
7
75
|
|
8
76
|
This release has major breaking changes. Read and test carefully in production.
|
9
77
|
|
10
|
-
- ActiveJobs can now use `sidekiq_options` directly to configure Sidekiq
|
78
|
+
- With Rails 6.0.1+, ActiveJobs can now use `sidekiq_options` directly to configure Sidekiq
|
11
79
|
features/internals like the retry subsystem. [#4213, pirj]
|
12
80
|
```ruby
|
13
81
|
class MyJob < ActiveJob::Base
|
@@ -17,6 +85,13 @@ class MyJob < ActiveJob::Base
|
|
17
85
|
end
|
18
86
|
end
|
19
87
|
```
|
88
|
+
- Logging has been redesigned to allow for pluggable log formatters:
|
89
|
+
```ruby
|
90
|
+
Sidekiq.configure_server do |config|
|
91
|
+
config.log_formatter = Sidekiq::Logger::Formatters::JSON.new
|
92
|
+
end
|
93
|
+
```
|
94
|
+
See the [Logging wiki page](https://github.com/mperham/sidekiq/wiki/Logging) for more details.
|
20
95
|
- **BREAKING CHANGE** Validate proper usage of the `REDIS_PROVIDER`
|
21
96
|
variable. This variable is meant to hold the name of the environment
|
22
97
|
variable which contains your Redis URL, so that you can switch Redis
|
data/Ent-Changes.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sidekiq (6.0.
|
4
|
+
sidekiq (6.0.1)
|
5
5
|
connection_pool (>= 2.2.2)
|
6
6
|
rack (>= 2.0.0)
|
7
7
|
rack-protection (>= 2.0.0)
|
@@ -97,7 +97,7 @@ GEM
|
|
97
97
|
nokogiri (1.10.4)
|
98
98
|
mini_portile2 (~> 2.4.0)
|
99
99
|
parallel (1.17.0)
|
100
|
-
parser (2.6.
|
100
|
+
parser (2.6.4.1)
|
101
101
|
ast (~> 2.4.0)
|
102
102
|
pry (0.12.2)
|
103
103
|
coderay (~> 1.1.0)
|
@@ -164,7 +164,7 @@ GEM
|
|
164
164
|
activesupport (>= 4.0)
|
165
165
|
sprockets (>= 3.0.0)
|
166
166
|
sqlite3 (1.4.1)
|
167
|
-
standard (0.1.
|
167
|
+
standard (0.1.4)
|
168
168
|
rubocop (~> 0.72.0)
|
169
169
|
rubocop-performance (~> 1.4.0)
|
170
170
|
thor (0.20.3)
|
data/Pro-Changes.md
CHANGED
@@ -4,12 +4,20 @@
|
|
4
4
|
|
5
5
|
Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy.
|
6
6
|
|
7
|
+
5.0.1
|
8
|
+
---------
|
9
|
+
|
10
|
+
- Rejigger batch failures UI to add direct links to retries and scheduled jobs [#4209]
|
11
|
+
- Delete batch data with `UNLINK` [#4155]
|
12
|
+
- Fix bug where a scheduled job can lose its scheduled time when using reliable push [#4267]
|
13
|
+
- Sidekiq::JobSet#scan and #find_job APIs have been promoted to Sidekiq OSS. [#4259]
|
14
|
+
|
7
15
|
5.0.0
|
8
16
|
---------
|
9
17
|
|
10
18
|
- There is no significant migration from Sidekiq Pro 4.0 to 5.0
|
11
19
|
but make sure you read the [update notes for Sidekiq
|
12
|
-
6.0](/mperham/sidekiq/blob/master/6.0-Upgrade.md).
|
20
|
+
6.0](https://github.com/mperham/sidekiq/blob/master/6.0-Upgrade.md).
|
13
21
|
- Removed various deprecated APIs and associated warnings.
|
14
22
|
- **BREAKING CHANGE** Remove the `Sidekiq::Batch::Status#dead_jobs` API in favor of
|
15
23
|
`Sidekiq::Batch::Status#dead_jids`. [#4217]
|
data/README.md
CHANGED
@@ -3,6 +3,7 @@ Sidekiq
|
|
3
3
|
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/sidekiq.svg)](https://rubygems.org/gems/sidekiq)
|
5
5
|
[![Code Climate](https://codeclimate.com/github/mperham/sidekiq.svg)](https://codeclimate.com/github/mperham/sidekiq)
|
6
|
+
[![Test Coverage](https://codeclimate.com/github/mperham/sidekiq/badges/coverage.svg)](https://codeclimate.com/github/mperham/sidekiq/coverage)
|
6
7
|
[![Build Status](https://circleci.com/gh/mperham/sidekiq/tree/master.svg?style=svg)](https://circleci.com/gh/mperham/sidekiq/tree/master)
|
7
8
|
[![Gitter Chat](https://badges.gitter.im/mperham/sidekiq.svg)](https://gitter.im/mperham/sidekiq)
|
8
9
|
|
data/bin/sidekiqload
CHANGED
@@ -5,7 +5,8 @@
|
|
5
5
|
$TESTING = false
|
6
6
|
|
7
7
|
#require 'ruby-prof'
|
8
|
-
|
8
|
+
require 'bundler/setup'
|
9
|
+
Bundler.require(:default, :load_test)
|
9
10
|
|
10
11
|
require_relative '../lib/sidekiq/cli'
|
11
12
|
require_relative '../lib/sidekiq/launcher'
|
@@ -102,17 +103,20 @@ iter.times do
|
|
102
103
|
end
|
103
104
|
Sidekiq.logger.error "Created #{count*iter} jobs"
|
104
105
|
|
106
|
+
start = Time.now
|
107
|
+
|
105
108
|
Monitoring = Thread.new do
|
106
109
|
watchdog("monitor thread") do
|
107
110
|
while true
|
108
|
-
sleep 0.
|
111
|
+
sleep 0.2
|
109
112
|
qsize = Sidekiq.redis do |conn|
|
110
113
|
conn.llen "queue:default"
|
111
114
|
end
|
112
115
|
total = qsize
|
113
|
-
Sidekiq.logger.error("RSS: #{Process.rss} Pending: #{total}")
|
116
|
+
#Sidekiq.logger.error("RSS: #{Process.rss} Pending: #{total}")
|
114
117
|
if total == 0
|
115
|
-
Sidekiq.logger.error("Done,
|
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")
|
116
120
|
|
117
121
|
LoadWorker.perform_async(1, Time.now.to_f)
|
118
122
|
LoadWorker.perform_async(2, Time.now.to_f)
|
data/bin/sidekiqmon
CHANGED
@@ -16,6 +16,8 @@ module Sidekiq
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def create_test_file
|
19
|
+
return unless test_framework
|
20
|
+
|
19
21
|
if defined?(RSpec)
|
20
22
|
create_worker_spec
|
21
23
|
else
|
@@ -42,6 +44,14 @@ module Sidekiq
|
|
42
44
|
)
|
43
45
|
template "worker_test.rb.erb", template_file
|
44
46
|
end
|
47
|
+
|
48
|
+
def file_name
|
49
|
+
@_file_name ||= super.sub(/_?worker\z/i, "")
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_framework
|
53
|
+
::Rails.application.config.generators.options[:rails][:test_framework]
|
54
|
+
end
|
45
55
|
end
|
46
56
|
end
|
47
57
|
end
|
data/lib/sidekiq.rb
CHANGED
@@ -192,6 +192,7 @@ module Sidekiq
|
|
192
192
|
|
193
193
|
def self.log_formatter=(log_formatter)
|
194
194
|
@log_formatter = log_formatter
|
195
|
+
logger.formatter = log_formatter
|
195
196
|
end
|
196
197
|
|
197
198
|
def self.logger
|
@@ -199,6 +200,13 @@ module Sidekiq
|
|
199
200
|
end
|
200
201
|
|
201
202
|
def self.logger=(logger)
|
203
|
+
if logger.nil?
|
204
|
+
self.logger.level = Logger::FATAL
|
205
|
+
return self.logger
|
206
|
+
end
|
207
|
+
|
208
|
+
logger.extend(Sidekiq::LoggingUtils)
|
209
|
+
|
202
210
|
@logger = logger
|
203
211
|
end
|
204
212
|
|
data/lib/sidekiq/api.rb
CHANGED
@@ -2,23 +2,11 @@
|
|
2
2
|
|
3
3
|
require "sidekiq"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
def sscan(conn, key)
|
8
|
-
cursor = "0"
|
9
|
-
result = []
|
10
|
-
loop do
|
11
|
-
cursor, values = conn.sscan(key, cursor)
|
12
|
-
result.push(*values)
|
13
|
-
break if cursor == "0"
|
14
|
-
end
|
15
|
-
result
|
16
|
-
end
|
17
|
-
end
|
5
|
+
require "zlib"
|
6
|
+
require "base64"
|
18
7
|
|
8
|
+
module Sidekiq
|
19
9
|
class Stats
|
20
|
-
include RedisScanner
|
21
|
-
|
22
10
|
def initialize
|
23
11
|
fetch_stats!
|
24
12
|
end
|
@@ -77,11 +65,11 @@ module Sidekiq
|
|
77
65
|
}
|
78
66
|
|
79
67
|
processes = Sidekiq.redis { |conn|
|
80
|
-
|
68
|
+
conn.sscan_each("processes").to_a
|
81
69
|
}
|
82
70
|
|
83
71
|
queues = Sidekiq.redis { |conn|
|
84
|
-
|
72
|
+
conn.sscan_each("queues").to_a
|
85
73
|
}
|
86
74
|
|
87
75
|
pipe2_res = Sidekiq.redis { |conn|
|
@@ -142,11 +130,9 @@ module Sidekiq
|
|
142
130
|
end
|
143
131
|
|
144
132
|
class Queues
|
145
|
-
include RedisScanner
|
146
|
-
|
147
133
|
def lengths
|
148
134
|
Sidekiq.redis do |conn|
|
149
|
-
queues =
|
135
|
+
queues = conn.sscan_each("queues").to_a
|
150
136
|
|
151
137
|
lengths = conn.pipelined {
|
152
138
|
queues.each do |queue|
|
@@ -225,13 +211,12 @@ module Sidekiq
|
|
225
211
|
#
|
226
212
|
class Queue
|
227
213
|
include Enumerable
|
228
|
-
extend RedisScanner
|
229
214
|
|
230
215
|
##
|
231
216
|
# Return all known queues within Redis.
|
232
217
|
#
|
233
218
|
def self.all
|
234
|
-
Sidekiq.redis { |c|
|
219
|
+
Sidekiq.redis { |c| c.sscan_each("queues").to_a }.sort.map { |q| Sidekiq::Queue.new(q) }
|
235
220
|
end
|
236
221
|
|
237
222
|
attr_reader :name
|
@@ -349,7 +334,7 @@ module Sidekiq
|
|
349
334
|
end
|
350
335
|
when "ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper"
|
351
336
|
job_class = @item["wrapped"] || args[0]
|
352
|
-
if job_class == "ActionMailer::DeliveryJob"
|
337
|
+
if job_class == "ActionMailer::DeliveryJob" || job_class == "ActionMailer::MailDeliveryJob"
|
353
338
|
# MailerClass#mailer_method
|
354
339
|
args[0]["arguments"][0..1].join("#")
|
355
340
|
else
|
@@ -372,6 +357,9 @@ module Sidekiq
|
|
372
357
|
if (self["wrapped"] || args[0]) == "ActionMailer::DeliveryJob"
|
373
358
|
# remove MailerClass, mailer_method and 'deliver_now'
|
374
359
|
job_args.drop(3)
|
360
|
+
elsif (self["wrapped"] || args[0]) == "ActionMailer::MailDeliveryJob"
|
361
|
+
# remove MailerClass, mailer_method and 'deliver_now'
|
362
|
+
job_args.drop(3).first["args"]
|
375
363
|
else
|
376
364
|
job_args
|
377
365
|
end
|
@@ -400,6 +388,20 @@ module Sidekiq
|
|
400
388
|
Time.at(self["created_at"] || self["enqueued_at"] || 0).utc
|
401
389
|
end
|
402
390
|
|
391
|
+
def tags
|
392
|
+
self["tags"] || []
|
393
|
+
end
|
394
|
+
|
395
|
+
def error_backtrace
|
396
|
+
# Cache nil values
|
397
|
+
if defined?(@error_backtrace)
|
398
|
+
@error_backtrace
|
399
|
+
else
|
400
|
+
value = self["error_backtrace"]
|
401
|
+
@error_backtrace = value && uncompress_backtrace(value)
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
403
405
|
attr_reader :queue
|
404
406
|
|
405
407
|
def latency
|
@@ -433,6 +435,17 @@ module Sidekiq
|
|
433
435
|
Sidekiq.logger.warn "Unable to load YAML: #{ex.message}" unless Sidekiq.options[:environment] == "development"
|
434
436
|
default
|
435
437
|
end
|
438
|
+
|
439
|
+
def uncompress_backtrace(backtrace)
|
440
|
+
if backtrace.is_a?(Array)
|
441
|
+
# Handle old jobs with previous backtrace format
|
442
|
+
backtrace
|
443
|
+
else
|
444
|
+
decoded = Base64.decode64(backtrace)
|
445
|
+
uncompressed = Zlib::Inflate.inflate(decoded)
|
446
|
+
Marshal.load(uncompressed)
|
447
|
+
end
|
448
|
+
end
|
436
449
|
end
|
437
450
|
|
438
451
|
class SortedEntry < Job
|
@@ -540,6 +553,17 @@ module Sidekiq
|
|
540
553
|
Sidekiq.redis { |c| c.zcard(name) }
|
541
554
|
end
|
542
555
|
|
556
|
+
def scan(match, count = 100)
|
557
|
+
return to_enum(:scan, match) unless block_given?
|
558
|
+
|
559
|
+
match = "*#{match}*" unless match.include?("*")
|
560
|
+
Sidekiq.redis do |conn|
|
561
|
+
conn.zscan_each(name, match: match, count: count) do |entry, score|
|
562
|
+
yield SortedEntry.new(self, score, entry)
|
563
|
+
end
|
564
|
+
end
|
565
|
+
end
|
566
|
+
|
543
567
|
def clear
|
544
568
|
Sidekiq.redis do |conn|
|
545
569
|
conn.del(name)
|
@@ -576,28 +600,40 @@ module Sidekiq
|
|
576
600
|
end
|
577
601
|
end
|
578
602
|
|
603
|
+
##
|
604
|
+
# Fetch jobs that match a given time or Range. Job ID is an
|
605
|
+
# optional second argument.
|
579
606
|
def fetch(score, jid = nil)
|
607
|
+
begin_score, end_score =
|
608
|
+
if score.is_a?(Range)
|
609
|
+
[score.first, score.last]
|
610
|
+
else
|
611
|
+
[score, score]
|
612
|
+
end
|
613
|
+
|
580
614
|
elements = Sidekiq.redis { |conn|
|
581
|
-
conn.zrangebyscore(name,
|
615
|
+
conn.zrangebyscore(name, begin_score, end_score, with_scores: true)
|
582
616
|
}
|
583
617
|
|
584
618
|
elements.each_with_object([]) do |element, result|
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
else
|
589
|
-
result << entry
|
590
|
-
end
|
619
|
+
data, job_score = element
|
620
|
+
entry = SortedEntry.new(self, job_score, data)
|
621
|
+
result << entry if jid.nil? || entry.jid == jid
|
591
622
|
end
|
592
623
|
end
|
593
624
|
|
594
625
|
##
|
595
626
|
# Find the job with the given JID within this sorted set.
|
596
|
-
#
|
597
|
-
# This is a slow, inefficient operation. Do not use under
|
598
|
-
# normal conditions. Sidekiq Pro contains a faster version.
|
627
|
+
# This is a slower O(n) operation. Do not use for app logic.
|
599
628
|
def find_job(jid)
|
600
|
-
|
629
|
+
Sidekiq.redis do |conn|
|
630
|
+
conn.zscan_each(name, match: "*#{jid}*", count: 100) do |entry, score|
|
631
|
+
job = JSON.parse(entry)
|
632
|
+
matched = job["jid"] == jid
|
633
|
+
return SortedEntry.new(self, score, entry) if matched
|
634
|
+
end
|
635
|
+
end
|
636
|
+
nil
|
601
637
|
end
|
602
638
|
|
603
639
|
def delete_by_value(name, value)
|
@@ -720,7 +756,6 @@ module Sidekiq
|
|
720
756
|
#
|
721
757
|
class ProcessSet
|
722
758
|
include Enumerable
|
723
|
-
include RedisScanner
|
724
759
|
|
725
760
|
def initialize(clean_plz = true)
|
726
761
|
cleanup if clean_plz
|
@@ -731,7 +766,7 @@ module Sidekiq
|
|
731
766
|
def cleanup
|
732
767
|
count = 0
|
733
768
|
Sidekiq.redis do |conn|
|
734
|
-
procs =
|
769
|
+
procs = conn.sscan_each("processes").to_a.sort
|
735
770
|
heartbeats = conn.pipelined {
|
736
771
|
procs.each do |key|
|
737
772
|
conn.hget(key, "info")
|
@@ -751,7 +786,7 @@ module Sidekiq
|
|
751
786
|
end
|
752
787
|
|
753
788
|
def each
|
754
|
-
procs = Sidekiq.redis { |conn|
|
789
|
+
procs = Sidekiq.redis { |conn| conn.sscan_each("processes").to_a }.sort
|
755
790
|
|
756
791
|
Sidekiq.redis do |conn|
|
757
792
|
# We're making a tradeoff here between consuming more memory instead of
|
@@ -885,11 +920,10 @@ module Sidekiq
|
|
885
920
|
#
|
886
921
|
class Workers
|
887
922
|
include Enumerable
|
888
|
-
include RedisScanner
|
889
923
|
|
890
924
|
def each
|
891
925
|
Sidekiq.redis do |conn|
|
892
|
-
procs =
|
926
|
+
procs = conn.sscan_each("processes").to_a
|
893
927
|
procs.sort.each do |key|
|
894
928
|
valid, workers = conn.pipelined {
|
895
929
|
conn.exists(key)
|
@@ -911,7 +945,7 @@ module Sidekiq
|
|
911
945
|
# which can easily get out of sync with crashy processes.
|
912
946
|
def size
|
913
947
|
Sidekiq.redis do |conn|
|
914
|
-
procs =
|
948
|
+
procs = conn.sscan_each("processes").to_a
|
915
949
|
if procs.empty?
|
916
950
|
0
|
917
951
|
else
|