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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1875ae5442c2ad0263c62be412c7401c209a22a6
4
- data.tar.gz: 14c2ca8f620ee209916ee8ae9eaecd0f5b910a67
3
+ metadata.gz: 6ad145a74f603f0fb35ab336670b69de2f4d15f5
4
+ data.tar.gz: a3f37457af73e6256eb1dbcfa5f6a5ac36c4d0b7
5
5
  SHA512:
6
- metadata.gz: a704641b059647ce845eab5a27dc717ee0fcdc81a1ca8a6a6778d3eccfc6d74e9e5f0f06588573dd7b95fd9f8042f2bf6d5e7edbcc831099b898db6381c6ea80
7
- data.tar.gz: 94e7334e76396fa1e40329571ef4b39b9b9a36d59a09fc69b1d7bf4fd8d9b9bce87f5110abf3bb46d46c79ce452bd78ff7410b761ad8fe2b7a144b7db448618a
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
@@ -35,7 +35,7 @@ module Sidekiq
35
35
  # if Sidekiq::VERSION >= '4'
36
36
  # Queues.jobs[queue].clear
37
37
  # else
38
- jobs.clear
38
+ jobs.clear
39
39
  # end
40
40
  end
41
41
 
@@ -66,4 +66,3 @@ module Sidekiq
66
66
  include Overrides
67
67
  end
68
68
  end
69
-
@@ -18,7 +18,7 @@ module SidekiqUniqueJobs
18
18
  end
19
19
  end
20
20
 
21
- def unlock_by_arguments(worker_class, unique_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
@@ -29,7 +29,7 @@ module SidekiqUniqueJobs
29
29
  connection { |conn| conn.scan_each(match: prefix(pattern), count: count).to_a }
30
30
  end
31
31
 
32
- def keys_by_keys(pattern, count)
32
+ def keys_by_keys(pattern, _count)
33
33
  connection { |conn| conn.keys(prefix(pattern)).to_a }
34
34
  end
35
35
 
@@ -1,3 +1,3 @@
1
1
  module SidekiqUniqueJobs
2
- VERSION = '4.0.11'
2
+ VERSION = '4.0.12'
3
3
  end
@@ -1,7 +1,16 @@
1
- local unique_key = KEYS[1]
2
- local stats_key = KEYS[2]
3
- local job_id = ARGV[1]
4
- local expires = ARGV[2]
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
@@ -2,6 +2,6 @@ class MyUniqueJob
2
2
  include Sidekiq::Worker
3
3
  sidekiq_options queue: :customqueue, retry: true, unique: :until_executed,
4
4
  unique_expiration: 7_200, retry_count: 10
5
- def perform(_)
5
+ def perform(_one, _two)
6
6
  end
7
7
  end
@@ -0,0 +1,10 @@
1
+ class NotifyWorker
2
+ include Sidekiq::Worker
3
+
4
+ sidekiq_options queue: :notify_worker,
5
+ unique: :until_executed
6
+
7
+ def perform(id, _blob)
8
+ puts "NotifyWorker -- #{id}"
9
+ end
10
+ end
@@ -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
- item = { 'class' => MyUniqueJob, 'queue' => 'customqueue', 'args' => [1, 2] }
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, keys: [key], argv: [jid, seconds])
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.11
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-12 00:00:00.000000000 Z
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