sidekiq-unique-jobs 4.0.11 → 4.0.12
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sidekiq-unique-jobs might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/sidekiq_unique_jobs/testing/sidekiq_overrides.rb +1 -2
- data/lib/sidekiq_unique_jobs/unlockable.rb +1 -1
- data/lib/sidekiq_unique_jobs/util.rb +1 -1
- data/lib/sidekiq_unique_jobs/version.rb +1 -1
- data/redis/aquire_lock.lua +13 -4
- data/spec/jobs/my_unique_job.rb +1 -1
- data/spec/jobs/notify_worker.rb +10 -0
- data/spec/lib/sidekiq_unique_jobs/client/middleware_spec.rb +25 -2
- data/spec/lib/sidekiq_unique_jobs/scripts_spec.rb +3 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ad145a74f603f0fb35ab336670b69de2f4d15f5
|
4
|
+
data.tar.gz: a3f37457af73e6256eb1dbcfa5f6a5ac36c4d0b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae02108f28fef4e4270b0b37c836191214b18c9e47b34ba5f7a6c0e748f7bf1c9cff5a9f4e9c9fde5deac0163b4e541eb127fe8f05cc2b68ef932e8ae79c3d57
|
7
|
+
data.tar.gz: 1e107f3d113d99d6e9e0c11e8f98718c782bfd7141a6b613eb2b295e1fb64caa205d97aeaf606b245bb9c0bf6cf42791330f22404ef9de9cbffb5bd560acc647
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## v4.0.12
|
2
|
+
|
3
|
+
- Allow jobs to be pushed to processing
|
4
|
+
- Close #150
|
5
|
+
- Close #151
|
6
|
+
- Close #146
|
7
|
+
- Close #136
|
8
|
+
- Close #133
|
9
|
+
|
1
10
|
## v4.0.11
|
2
11
|
|
3
12
|
- Always load forwardable - https://github.com/mhenrixon/sidekiq-unique-jobs/issues/152#issuecomment-164199978
|
@@ -18,7 +18,7 @@ module SidekiqUniqueJobs
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
def unlock_by_arguments(
|
21
|
+
def unlock_by_arguments(_worker_class, _unique_arguments = {})
|
22
22
|
Scripts.call(:release_lock, redis_pool, keys: [unique_key], argv: [jid]) do |result|
|
23
23
|
after_unlock(result, __method__)
|
24
24
|
end
|
data/redis/aquire_lock.lua
CHANGED
@@ -1,7 +1,16 @@
|
|
1
|
-
local unique_key
|
2
|
-
local
|
3
|
-
local
|
4
|
-
local
|
1
|
+
local unique_key = KEYS[1]
|
2
|
+
local job_id = ARGV[1]
|
3
|
+
local expires = ARGV[2]
|
4
|
+
local scheduled = ARGV[3]
|
5
|
+
local stored_jid = redis.pcall('get', unique_key)
|
6
|
+
|
7
|
+
if stored_jid then
|
8
|
+
if stored_jid == job_id then
|
9
|
+
return 1
|
10
|
+
else
|
11
|
+
return 0
|
12
|
+
end
|
13
|
+
end
|
5
14
|
|
6
15
|
if redis.pcall('set', unique_key, job_id, 'nx', 'ex', expires) then
|
7
16
|
return 1
|
data/spec/jobs/my_unique_job.rb
CHANGED
@@ -15,6 +15,30 @@ RSpec.describe SidekiqUniqueJobs::Client::Middleware do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
describe 'when a job is already scheduled' do
|
18
|
+
|
19
|
+
it 'processes jobs properly', sidekiq_ver: '>= 4.0.0' do
|
20
|
+
Sidekiq::Testing.disable! do
|
21
|
+
jid = NotifyWorker.perform_in(1, 183, 'xxxx')
|
22
|
+
expect(jid).not_to eq(nil)
|
23
|
+
Sidekiq.redis do |c|
|
24
|
+
expect(c.zcard('schedule')).to eq(1)
|
25
|
+
expect(c.keys).to match_array(%w(schedule uniquejobs:6e47d668ad22db2a3ba0afd331514ce2))
|
26
|
+
end
|
27
|
+
sleep 1
|
28
|
+
Sidekiq::Scheduled::Enq.new.enqueue_jobs
|
29
|
+
|
30
|
+
Sidekiq.redis do |c|
|
31
|
+
wait(10).for { c.llen('queue:notify_worker') }.to eq(1)
|
32
|
+
end
|
33
|
+
|
34
|
+
Sidekiq::Simulator.process_queue(:notify_worker) do
|
35
|
+
Sidekiq.redis do |c|
|
36
|
+
wait(10).for { c.llen('queue:notify_worker') }.to eq(0)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
18
42
|
it 'rejects nested subsequent jobs with the same arguments', sidekiq_ver: '>= 3.5.3' do
|
19
43
|
Sidekiq::Testing.disable! do
|
20
44
|
expect(SimpleWorker.perform_async 1).not_to eq(nil)
|
@@ -87,8 +111,7 @@ RSpec.describe SidekiqUniqueJobs::Client::Middleware do
|
|
87
111
|
end
|
88
112
|
|
89
113
|
it 'does not push duplicate messages when configured for unique only' do
|
90
|
-
|
91
|
-
10.times { Sidekiq::Client.push(item) }
|
114
|
+
10.times { MyUniqueJob.perform_async(1, 2) }
|
92
115
|
Sidekiq.redis do |c|
|
93
116
|
expect(c.llen('queue:customqueue')).to eq(1)
|
94
117
|
end
|
@@ -24,7 +24,7 @@ RSpec.describe SidekiqUniqueJobs::Scripts do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def lock_for(seconds = 1, jid = JID, key = UNIQUE_KEY)
|
27
|
-
subject.call(:aquire_lock, nil,
|
27
|
+
subject.call(:aquire_lock, nil, keys: [key], argv: [jid, seconds])
|
28
28
|
end
|
29
29
|
|
30
30
|
def unlock(key = UNIQUE_KEY, jid = JID)
|
@@ -45,8 +45,8 @@ RSpec.describe SidekiqUniqueJobs::Scripts do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
context 'when job is locked' do
|
48
|
-
before { expect(lock_for).to eq(1) }
|
49
|
-
specify { expect(lock_for).to eq(0) }
|
48
|
+
before { expect(lock_for(10)).to eq(1) }
|
49
|
+
specify { expect(lock_for(5, 'anotherjid')).to eq(0) }
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-unique-jobs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikael Henriksson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -242,6 +242,7 @@ files:
|
|
242
242
|
- spec/jobs/main_job.rb
|
243
243
|
- spec/jobs/my_job.rb
|
244
244
|
- spec/jobs/my_unique_job.rb
|
245
|
+
- spec/jobs/notify_worker.rb
|
245
246
|
- spec/jobs/plain_class.rb
|
246
247
|
- spec/jobs/simple_worker.rb
|
247
248
|
- spec/jobs/spawn_simple_worker.rb
|