sidekiq 4.0.0 → 4.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/4.0-Upgrade.md +1 -11
- data/Changes.md +7 -11
- data/lib/sidekiq/launcher.rb +2 -2
- data/lib/sidekiq/testing.rb +14 -84
- data/lib/sidekiq/version.rb +1 -1
- data/test/test_testing_fake.rb +1 -64
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 624586e09bcac2fc2e2a4a809f5ba7c66e270e05
|
4
|
+
data.tar.gz: dc0f6f0ba020ac0b846e89c8310918a87d4d00c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c707028cf7bc1549c8cf5a8410867f4709c304e9490a936490cd3c068b8449a0304a17f4855d49f2ee62f829326fc3be0063a87f86bb2af34a34ed0466e40a5b
|
7
|
+
data.tar.gz: cdbaa525bcb6d18b9f265f44d568c1d64d74c328c66c1d7d30fe2818d40fb4321330f532c708a76a8cd620cb545d6c86677e79c3b23bb8b520dd0d20edd1ae96
|
data/4.0-Upgrade.md
CHANGED
@@ -17,7 +17,7 @@ gem 'redis-namespace'
|
|
17
17
|
* **Redis 2.8.0 or greater is required.** Redis 2.8 was released two years
|
18
18
|
ago and contains **many** useful features which Sidekiq couldn't
|
19
19
|
leverage until now. **Redis 3.0.3 or greater is recommended** for large
|
20
|
-
scale use.
|
20
|
+
scale use [#2431](https://github.com/mperham/sidekiq/issues/2431).
|
21
21
|
|
22
22
|
* Jobs are now fetched from Redis in parallel, making Sidekiq more
|
23
23
|
resilient to high network latency. This means that Sidekiq requires
|
@@ -25,16 +25,6 @@ gem 'redis-namespace'
|
|
25
25
|
`concurrency + 2` connections in your pool or Sidekiq will exit.
|
26
26
|
When in doubt, let Sidekiq size the connection pool for you.
|
27
27
|
|
28
|
-
* There's a new testing API based off the `Sidekiq::Queues` namespace. All
|
29
|
-
assertions made against the Worker class still work as expected.
|
30
|
-
```ruby
|
31
|
-
assert_equal 0, Sidekiq::Queues["default"].size
|
32
|
-
HardWorker.perform_async("log")
|
33
|
-
assert_equal 1, Sidekiq::Queues["default"].size
|
34
|
-
assert_equal "log", Sidekiq::Queues["default"].first['args'][0]
|
35
|
-
Sidekiq::Queues.clear_all
|
36
|
-
```
|
37
|
-
|
38
28
|
## Upgrade
|
39
29
|
|
40
30
|
First, make sure you are using Redis 2.8 or greater. Next:
|
data/Changes.md
CHANGED
@@ -1,22 +1,18 @@
|
|
1
1
|
# Sidekiq Changes
|
2
2
|
|
3
|
-
4.0.
|
3
|
+
4.0.1
|
4
|
+
-----------
|
5
|
+
|
6
|
+
- Yank new queue-based testing API [#2663]
|
7
|
+
- Fix invalid constant reference in heartbeat
|
8
|
+
|
9
|
+
4.0.0
|
4
10
|
-----------
|
5
11
|
|
6
12
|
- Sidekiq's internals have been completely overhauled for performance
|
7
13
|
and to remove dependencies. This has resulted in major speedups, as
|
8
14
|
[detailed on my blog](http://www.mikeperham.com/2015/10/14/optimizing-sidekiq/).
|
9
15
|
- See the [4.0 upgrade notes](4.0-Upgrade.md) for more detail.
|
10
|
-
- There's a new testing API based off the `Sidekiq::Queues` namespace. All
|
11
|
-
assertions made against the Worker class still work as expected.
|
12
|
-
[#2659, brandonhilkert]
|
13
|
-
```ruby
|
14
|
-
assert_equal 0, Sidekiq::Queues["default"].size
|
15
|
-
HardWorker.perform_async("log")
|
16
|
-
assert_equal 1, Sidekiq::Queues["default"].size
|
17
|
-
assert_equal "log", Sidekiq::Queues["default"].first['args'][0]
|
18
|
-
Sidekiq::Queues.clear_all
|
19
|
-
```
|
20
16
|
|
21
17
|
3.5.3
|
22
18
|
-----------
|
data/lib/sidekiq/launcher.rb
CHANGED
@@ -112,8 +112,8 @@ module Sidekiq
|
|
112
112
|
# ignore all redis/network issues
|
113
113
|
logger.error("heartbeat: #{e.message}")
|
114
114
|
# don't lose the counts if there was a network issue
|
115
|
-
PROCESSED.increment(procd)
|
116
|
-
FAILURE.increment(fails)
|
115
|
+
Processor::PROCESSED.increment(procd)
|
116
|
+
Processor::FAILURE.increment(fails)
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
data/lib/sidekiq/testing.rb
CHANGED
@@ -68,15 +68,15 @@ module Sidekiq
|
|
68
68
|
def raw_push(payloads)
|
69
69
|
if Sidekiq::Testing.fake?
|
70
70
|
payloads.each do |job|
|
71
|
-
|
71
|
+
job['class'].constantize.jobs << Sidekiq.load_json(Sidekiq.dump_json(job))
|
72
72
|
end
|
73
73
|
true
|
74
74
|
elsif Sidekiq::Testing.inline?
|
75
75
|
payloads.each do |job|
|
76
|
+
job['jid'] ||= SecureRandom.hex(12)
|
76
77
|
klass = job['class'].constantize
|
77
|
-
|
78
|
-
|
79
|
-
klass.process_job(job_hash)
|
78
|
+
klass.jobs.unshift Sidekiq.load_json(Sidekiq.dump_json(job))
|
79
|
+
klass.perform_one
|
80
80
|
end
|
81
81
|
true
|
82
82
|
else
|
@@ -85,64 +85,6 @@ module Sidekiq
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
module Queues
|
89
|
-
##
|
90
|
-
# The Queues class is only for testing the fake queue implementation.
|
91
|
-
# The data is structured as a hash with queue name as hash key and array
|
92
|
-
# of job data as the value.
|
93
|
-
#
|
94
|
-
# {
|
95
|
-
# "default"=>[
|
96
|
-
# {
|
97
|
-
# "class"=>"TestTesting::QueueWorker",
|
98
|
-
# "args"=>[1, 2],
|
99
|
-
# "retry"=>true,
|
100
|
-
# "queue"=>"default",
|
101
|
-
# "jid"=>"abc5b065c5c4b27fc1102833",
|
102
|
-
# "created_at"=>1447445554.419934
|
103
|
-
# }
|
104
|
-
# ]
|
105
|
-
# }
|
106
|
-
#
|
107
|
-
# Example:
|
108
|
-
#
|
109
|
-
# require 'sidekiq/testing'
|
110
|
-
#
|
111
|
-
# assert_equal 0, Sidekiq::Queues["default"].size
|
112
|
-
# HardWorker.perform_async(:something)
|
113
|
-
# assert_equal 1, Sidekiq::Queues["default"].size
|
114
|
-
# assert_equal :something, Sidekiq::Queues["default"].first['args'][0]
|
115
|
-
#
|
116
|
-
# You can also clear all workers' jobs:
|
117
|
-
#
|
118
|
-
# assert_equal 0, Sidekiq::Queues["default"].size
|
119
|
-
# HardWorker.perform_async(:something)
|
120
|
-
# Sidekiq::Queues.clear_all
|
121
|
-
# assert_equal 0, Sidekiq::Queues["default"].size
|
122
|
-
#
|
123
|
-
# This can be useful to make sure jobs don't linger between tests:
|
124
|
-
#
|
125
|
-
# RSpec.configure do |config|
|
126
|
-
# config.before(:each) do
|
127
|
-
# Sidekiq::Queues.clear_all
|
128
|
-
# end
|
129
|
-
# end
|
130
|
-
#
|
131
|
-
class << self
|
132
|
-
def [](queue)
|
133
|
-
jobs[queue.to_s]
|
134
|
-
end
|
135
|
-
|
136
|
-
def jobs
|
137
|
-
@jobs ||= Hash.new { |hash, key| hash[key] = [] }
|
138
|
-
end
|
139
|
-
|
140
|
-
def clear_all
|
141
|
-
jobs.clear
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
88
|
module Worker
|
147
89
|
##
|
148
90
|
# The Sidekiq testing infrastructure overrides perform_async
|
@@ -201,36 +143,28 @@ module Sidekiq
|
|
201
143
|
#
|
202
144
|
module ClassMethods
|
203
145
|
|
204
|
-
# Queue for this worker
|
205
|
-
def queue
|
206
|
-
self.sidekiq_options["queue"].to_s
|
207
|
-
end
|
208
|
-
|
209
146
|
# Jobs queued for this worker
|
210
147
|
def jobs
|
211
|
-
|
148
|
+
Worker.jobs[self]
|
212
149
|
end
|
213
150
|
|
214
151
|
# Clear all jobs for this worker
|
215
152
|
def clear
|
216
|
-
|
153
|
+
jobs.clear
|
217
154
|
end
|
218
155
|
|
219
156
|
# Drain and run all jobs for this worker
|
220
157
|
def drain
|
221
|
-
while jobs.
|
222
|
-
|
223
|
-
Queues.jobs[queue].delete_if { |job| job["jid"] == next_job["jid"] }
|
224
|
-
process_job(next_job)
|
158
|
+
while job = jobs.shift do
|
159
|
+
process_job(job)
|
225
160
|
end
|
226
161
|
end
|
227
162
|
|
228
163
|
# Pop out a single job and perform it
|
229
164
|
def perform_one
|
230
165
|
raise(EmptyQueueError, "perform_one called with empty job queue") if jobs.empty?
|
231
|
-
|
232
|
-
|
233
|
-
process_job(next_job)
|
166
|
+
job = jobs.shift
|
167
|
+
process_job(job)
|
234
168
|
end
|
235
169
|
|
236
170
|
def process_job(job)
|
@@ -249,22 +183,18 @@ module Sidekiq
|
|
249
183
|
|
250
184
|
class << self
|
251
185
|
def jobs # :nodoc:
|
252
|
-
|
186
|
+
@jobs ||= Hash.new { |hash, key| hash[key] = [] }
|
253
187
|
end
|
254
188
|
|
255
189
|
# Clear all queued jobs across all workers
|
256
190
|
def clear_all
|
257
|
-
|
191
|
+
jobs.clear
|
258
192
|
end
|
259
193
|
|
260
194
|
# Drain all queued jobs across all workers
|
261
195
|
def drain_all
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
worker_classes.each do |worker_class|
|
266
|
-
worker_class.constantize.drain
|
267
|
-
end
|
196
|
+
until jobs.values.all?(&:empty?) do
|
197
|
+
jobs.keys.each(&:drain)
|
268
198
|
end
|
269
199
|
end
|
270
200
|
end
|
data/lib/sidekiq/version.rb
CHANGED
data/test/test_testing_fake.rb
CHANGED
@@ -54,7 +54,6 @@ class TestTesting < Sidekiq::Test
|
|
54
54
|
|
55
55
|
after do
|
56
56
|
Sidekiq::Testing.disable!
|
57
|
-
Sidekiq::Queues.clear_all
|
58
57
|
end
|
59
58
|
|
60
59
|
it 'stubs the async call' do
|
@@ -94,7 +93,7 @@ class TestTesting < Sidekiq::Test
|
|
94
93
|
it 'stubs the enqueue_to call' do
|
95
94
|
assert_equal 0, EnqueuedWorker.jobs.size
|
96
95
|
assert Sidekiq::Client.enqueue_to('someq', EnqueuedWorker, 1, 2)
|
97
|
-
assert_equal 1,
|
96
|
+
assert_equal 1, EnqueuedWorker.jobs.size
|
98
97
|
end
|
99
98
|
|
100
99
|
it 'executes all stored jobs' do
|
@@ -264,68 +263,6 @@ class TestTesting < Sidekiq::Test
|
|
264
263
|
it 'can execute a job' do
|
265
264
|
DirectWorker.execute_job(DirectWorker.new, [2, 3])
|
266
265
|
end
|
267
|
-
end
|
268
|
-
|
269
|
-
describe 'queue testing' do
|
270
|
-
before do
|
271
|
-
require 'sidekiq/testing'
|
272
|
-
Sidekiq::Testing.fake!
|
273
|
-
end
|
274
|
-
|
275
|
-
after do
|
276
|
-
Sidekiq::Testing.disable!
|
277
|
-
Sidekiq::Queues.clear_all
|
278
|
-
end
|
279
266
|
|
280
|
-
class QueueWorker
|
281
|
-
include Sidekiq::Worker
|
282
|
-
def perform(a, b)
|
283
|
-
a + b
|
284
|
-
end
|
285
|
-
end
|
286
|
-
|
287
|
-
class AltQueueWorker
|
288
|
-
include Sidekiq::Worker
|
289
|
-
sidekiq_options queue: :alt
|
290
|
-
def perform(a, b)
|
291
|
-
a + b
|
292
|
-
end
|
293
|
-
end
|
294
|
-
|
295
|
-
it 'finds enqueued jobs' do
|
296
|
-
assert_equal 0, Sidekiq::Queues["default"].size
|
297
|
-
|
298
|
-
QueueWorker.perform_async(1, 2)
|
299
|
-
QueueWorker.perform_async(1, 2)
|
300
|
-
AltQueueWorker.perform_async(1, 2)
|
301
|
-
|
302
|
-
assert_equal 2, Sidekiq::Queues["default"].size
|
303
|
-
assert_equal [1, 2], Sidekiq::Queues["default"].first["args"]
|
304
|
-
|
305
|
-
assert_equal 1, Sidekiq::Queues["alt"].size
|
306
|
-
end
|
307
|
-
|
308
|
-
it 'clears out all queues' do
|
309
|
-
assert_equal 0, Sidekiq::Queues["default"].size
|
310
|
-
|
311
|
-
QueueWorker.perform_async(1, 2)
|
312
|
-
QueueWorker.perform_async(1, 2)
|
313
|
-
AltQueueWorker.perform_async(1, 2)
|
314
|
-
|
315
|
-
Sidekiq::Queues.clear_all
|
316
|
-
|
317
|
-
assert_equal 0, Sidekiq::Queues["default"].size
|
318
|
-
assert_equal 0, Sidekiq::Queues["alt"].size
|
319
|
-
end
|
320
|
-
|
321
|
-
it 'finds jobs enqueued by client' do
|
322
|
-
Sidekiq::Client.push(
|
323
|
-
'class' => 'NonExistentWorker',
|
324
|
-
'queue' => 'missing',
|
325
|
-
'args' => [1]
|
326
|
-
)
|
327
|
-
|
328
|
-
assert_equal 1, Sidekiq::Queues["missing"].size
|
329
|
-
end
|
330
267
|
end
|
331
268
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Perham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|