sidekiq-middleware 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ 0.1.2
2
+ -----------
3
+
4
+ - Fixed unique jobs server middleware to clear lock only when unique is enabled
5
+
1
6
  0.1.1
2
7
  -----------
3
8
 
@@ -28,7 +28,8 @@ module Sidekiq
28
28
  end
29
29
 
30
30
  def clear(worker_instance, item, queue)
31
- Sidekiq.redis { |conn| conn.del unique_lock_key(worker_instance, item, queue) }
31
+ enabled = worker_instance.class.get_sidekiq_options['unique']
32
+ Sidekiq.redis { |conn| conn.del unique_lock_key(worker_instance, item, queue) } if enabled
32
33
  end
33
34
  end
34
35
  end
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Middleware
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -62,10 +62,9 @@ class TestUniqueJobs < MiniTest::Unit::TestCase
62
62
 
63
63
  class UniqueScheduledWorker
64
64
  include Sidekiq::Worker
65
- sidekiq_options queue: :unique_scheduled_queue, unique: :all, manual: true
65
+ sidekiq_options queue: :unique_scheduled_queue, unique: :all
66
66
 
67
67
  def perform(x)
68
- UniqueScheduledWorker.perform_in(60, x)
69
68
  end
70
69
  end
71
70
 
@@ -74,6 +73,24 @@ class TestUniqueJobs < MiniTest::Unit::TestCase
74
73
  assert_equal 1, Sidekiq.redis { |c| c.zcard('schedule') }
75
74
  end
76
75
 
76
+ it 'allows the job to be re-scheduled after processing' do
77
+ # Schedule
78
+ 5.times { |t| UniqueScheduledWorker.perform_in((t+1)*60, 'args') }
79
+ assert_equal 1, Sidekiq.redis { |c| c.zcard('schedule') }
80
+
81
+ # Process
82
+ msg = Sidekiq.dump_json('class' => UniqueScheduledWorker.to_s, 'queue' => 'unique_scheduled_queue', 'args' => ['args'])
83
+ actor = MiniTest::Mock.new
84
+ actor.expect(:processor_done, nil, [@processor])
85
+ @boss.expect(:async, actor, [])
86
+ work = UnitOfWork.new('default', msg)
87
+ @processor.process(work)
88
+
89
+ # Re-schedule
90
+ 5.times { |t| UniqueScheduledWorker.perform_in((t+1)*60, 'args') }
91
+ assert_equal 2, Sidekiq.redis { |c| c.zcard('schedule') }
92
+ end
93
+
77
94
  class CustomUniqueWorker
78
95
  include Sidekiq::Worker
79
96
  sidekiq_options queue: :custom_unique_queue, unique: :all, manual: true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-middleware
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-06 00:00:00.000000000 Z
12
+ date: 2013-05-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sidekiq
@@ -98,7 +98,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  segments:
100
100
  - 0
101
- hash: -293936533653775509
101
+ hash: -2342858666365224012
102
102
  required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  none: false
104
104
  requirements:
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  segments:
109
109
  - 0
110
- hash: -293936533653775509
110
+ hash: -2342858666365224012
111
111
  requirements: []
112
112
  rubyforge_project:
113
113
  rubygems_version: 1.8.24