sidekiq-unique-jobs 3.0.7 → 3.0.8

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: 9383c56f2a6657bf08a95665b1e7569e5972a6d4
4
- data.tar.gz: f7c28d6590747bbfb1636b4db004efe0d09f2a9c
3
+ metadata.gz: 8554798396c72d3690d539a5c8fb28fbf25a9333
4
+ data.tar.gz: ae6a41b82e11b7b8d4526a4a9c4a5cd374d7c36c
5
5
  SHA512:
6
- metadata.gz: 52589e4651aaf61fdde58b3bc6f0deda32f1970a7854f6977b5b4b846ba62952aedc42854fac1e954d1af78b5ba4e63389637c05fad5a3e19c13c7d26e2a0155
7
- data.tar.gz: 099123ebfba9fb16bd3723ae505e78b2133a4f3d8630b471b2bce30af7593cb8c1ffb3a7c2e06b91d0ad14d5e810938b28e225a06ea21789f31a19e217561039
6
+ metadata.gz: 804380e5c2f608a6b162cfd48c43e36d28e8a50ba860b4eff1aaf6cd51dbb5007652407a7f18abad62ab9d667a1652c140fc9999f6866757bb493cd2b05f254f
7
+ data.tar.gz: c6bdd3053362b0893d478d4a85956796d792e7cdcf0be4b62a131a07e3abf6ebfea871138270166a8f4d8366fd72e026324192fb031f026132129c0e3041c85a
@@ -0,0 +1,68 @@
1
+ require 'sidekiq/api'
2
+
3
+ module Sidekiq
4
+ class Job
5
+ module UniqueExtension
6
+ def self.included(base)
7
+ base.class_eval do
8
+ alias_method :delete_orig, :delete
9
+ alias_method :delete, :delete_ext
10
+ end
11
+ end
12
+
13
+ def delete_ext
14
+ unlock(payload_hash(item))
15
+ delete_orig
16
+ end
17
+
18
+ protected
19
+
20
+ def payload_hash(item)
21
+ SidekiqUniqueJobs::PayloadHelper.get_payload(item['class'], item['queue'], item['args'])
22
+ end
23
+
24
+ def unlock(payload_hash)
25
+ Sidekiq.redis { |conn| conn.del(payload_hash) }
26
+ end
27
+ end
28
+ include UniqueExtension
29
+ end
30
+
31
+ class Queue
32
+ module UniqueExtension
33
+ def self.included(base)
34
+ base.class_eval do
35
+ alias_method :clear_orig, :clear
36
+ alias_method :clear, :clear_ext
37
+ end
38
+ end
39
+
40
+ def clear_ext
41
+ each(&:delete)
42
+ clear_orig
43
+ end
44
+ end
45
+
46
+ include UniqueExtension
47
+ end
48
+
49
+ class JobSet
50
+ module UniqueExtension
51
+ def self.included(base)
52
+ base.class_eval do
53
+ if base.method_defined?(:clear)
54
+ alias_method :clear_orig, :clear
55
+ alias_method :clear, :clear_ext
56
+ end
57
+ end
58
+ end
59
+
60
+ def clear_ext
61
+ each(&:delete_ext)
62
+ clear_orig
63
+ end
64
+ end
65
+
66
+ include UniqueExtension
67
+ end
68
+ end
@@ -1,3 +1,3 @@
1
1
  module SidekiqUniqueJobs
2
- VERSION = '3.0.7'
2
+ VERSION = '3.0.8'
3
3
  end
@@ -4,7 +4,6 @@ require 'sidekiq-unique-jobs'
4
4
  require 'sidekiq/scheduled'
5
5
  require 'sidekiq_unique_jobs/middleware/server/unique_jobs'
6
6
  require 'active_support/testing/time_helpers'
7
- require 'active_support/core_ext'
8
7
  require 'rspec-sidekiq'
9
8
 
10
9
  describe 'When Sidekiq::Testing is enabled' do
@@ -114,7 +113,7 @@ describe 'When Sidekiq::Testing is enabled' do
114
113
  InlineExpirationWorker.perform_async(2)
115
114
  expect(TestClass).to have_received(:run).with(1).once
116
115
  expect(TestClass).to have_received(:run).with(2).once
117
- travel_to(11.minutes.from_now) do
116
+ travel_to(Time.now + (11 * 60)) do
118
117
  InlineExpirationWorker.perform_async(1)
119
118
  end
120
119
 
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+ require 'sidekiq/api'
3
+ require 'sidekiq/worker'
4
+ require 'sidekiq_unique_jobs/middleware/server/unique_jobs'
5
+ require 'sidekiq_unique_jobs/middleware/client/unique_jobs'
6
+ require 'sidekiq_unique_jobs/sidekiq_unique_ext'
7
+
8
+ class JustAWorker
9
+ include Sidekiq::Worker
10
+
11
+ sidekiq_options unique: true, queue: 'testqueue'
12
+
13
+ def perform
14
+ end
15
+ end
16
+
17
+ describe Sidekiq::Job::UniqueExtension do
18
+
19
+ before do
20
+ Sidekiq.redis = REDIS
21
+ Sidekiq.redis(&:flushdb)
22
+ end
23
+
24
+ it 'deletes uniqueness lock on delete' do
25
+ params = { foo: 'bar' }
26
+ payload_hash = SidekiqUniqueJobs::PayloadHelper.get_payload('JustAWorker', 'testqueue', [params])
27
+ jid = JustAWorker.perform_async(foo: 'bar')
28
+ queue = Sidekiq::Queue.new('testqueue')
29
+ job = queue.find_job(jid)
30
+ job.delete
31
+ Sidekiq.redis do |c|
32
+ expect(c.exists(payload_hash)).to be_falsy
33
+ end
34
+ end
35
+ end
36
+
37
+ describe Sidekiq::Queue::UniqueExtension do
38
+
39
+ before do
40
+ Sidekiq.redis = REDIS
41
+ Sidekiq.redis(&:flushdb)
42
+ end
43
+
44
+ it 'deletes uniqueness locks on clear' do
45
+ params = { foo: 'bar' }
46
+ payload_hash = SidekiqUniqueJobs::PayloadHelper.get_payload('JustAWorker', 'testqueue', [params])
47
+ JustAWorker.perform_async(foo: 'bar')
48
+ queue = Sidekiq::Queue.new('testqueue')
49
+ queue.clear
50
+ Sidekiq.redis do |c|
51
+ expect(c.exists(payload_hash)).to be_falsy
52
+ end
53
+ end
54
+ end
55
+
56
+ describe Sidekiq::JobSet::UniqueExtension, sidekiq_ver: 3 do
57
+
58
+ before do
59
+ Sidekiq.redis = REDIS
60
+ Sidekiq.redis(&:flushdb)
61
+ end
62
+
63
+ it 'deletes uniqueness locks on clear' do
64
+ params = { foo: 'bar' }
65
+ payload_hash = SidekiqUniqueJobs::PayloadHelper.get_payload('JustAWorker', 'testqueue', [params])
66
+ JustAWorker.perform_in(60 * 60 * 3, foo: 'bar')
67
+ set = Sidekiq::JobSet.new('schedule')
68
+ set.clear
69
+ Sidekiq.redis do |c|
70
+ expect(c.exists(payload_hash)).to be_falsy
71
+ end
72
+ end
73
+ end
@@ -4,6 +4,11 @@ RSpec.configure do |config|
4
4
  sidekiq = :fake if sidekiq == true
5
5
  Sidekiq::Testing.send("#{sidekiq}!")
6
6
  end
7
+
8
+ sidekiq_ver = example.metadata[:sidekiq_ver]
9
+ if sidekiq_ver && Sidekiq::VERSION[0].to_s != sidekiq_ver.to_s
10
+ skip("Not relevant for version #{sidekiq_ver}")
11
+ end
7
12
  end
8
13
 
9
14
  config.after(:each) do |example|
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: 3.0.7
4
+ version: 3.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-03 00:00:00.000000000 Z
11
+ date: 2014-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -156,6 +156,7 @@ files:
156
156
  - lib/sidekiq_unique_jobs/middleware/client/unique_jobs.rb
157
157
  - lib/sidekiq_unique_jobs/middleware/server/unique_jobs.rb
158
158
  - lib/sidekiq_unique_jobs/payload_helper.rb
159
+ - lib/sidekiq_unique_jobs/sidekiq_unique_ext.rb
159
160
  - lib/sidekiq_unique_jobs/testing.rb
160
161
  - lib/sidekiq_unique_jobs/version.rb
161
162
  - sidekiq-unique-jobs.gemspec
@@ -163,6 +164,7 @@ files:
163
164
  - spec/lib/client_spec.rb
164
165
  - spec/lib/middleware/server/unique_jobs_spec.rb
165
166
  - spec/lib/sidekiq_testing_enabled_spec.rb
167
+ - spec/lib/sidekiq_unique_ext_spec.rb
166
168
  - spec/lib/unlock_order_spec.rb
167
169
  - spec/spec_helper.rb
168
170
  - spec/support/my_worker.rb