sidekiq-unique-jobs 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of sidekiq-unique-jobs might be problematic. Click here for more details.
data/Gemfile
CHANGED
@@ -5,9 +5,16 @@ gem 'celluloid'
|
|
5
5
|
gem 'slim'
|
6
6
|
gem 'sprockets'
|
7
7
|
gem 'sass'
|
8
|
-
gem 'rails', '3.2.
|
8
|
+
gem 'rails', '3.2.8'
|
9
9
|
gem 'sqlite3'
|
10
10
|
|
11
11
|
group :test do
|
12
12
|
gem 'simplecov', :require => false
|
13
|
+
end
|
14
|
+
|
15
|
+
group :development do
|
16
|
+
gem 'pry'
|
17
|
+
gem 'pry-doc'
|
18
|
+
gem 'pry-stack_explorer'
|
19
|
+
gem 'pry-debugger'
|
13
20
|
end
|
@@ -23,8 +23,11 @@ module SidekiqUniqueJobs
|
|
23
23
|
if conn.get(payload_hash)
|
24
24
|
conn.unwatch
|
25
25
|
else
|
26
|
+
expires_at = HASH_KEY_EXPIRATION
|
27
|
+
expires_at = ((Time.at(item['at']) - Time.now.utc) * 24 * 60 * 60).to_i if item['at']
|
28
|
+
|
26
29
|
unique = conn.multi do
|
27
|
-
conn.setex(payload_hash,
|
30
|
+
conn.setex(payload_hash, expires_at, 1)
|
28
31
|
end
|
29
32
|
end
|
30
33
|
end
|
data/test/helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'helper'
|
2
2
|
require 'sidekiq/worker'
|
3
3
|
require "sidekiq-unique-jobs"
|
4
|
+
require 'sidekiq/scheduled'
|
4
5
|
|
5
6
|
class TestClient < MiniTest::Unit::TestCase
|
6
7
|
describe 'with real redis' do
|
@@ -12,6 +13,8 @@ class TestClient < MiniTest::Unit::TestCase
|
|
12
13
|
class QueueWorker
|
13
14
|
include Sidekiq::Worker
|
14
15
|
sidekiq_options :queue => 'customqueue'
|
16
|
+
def perform(x)
|
17
|
+
end
|
15
18
|
end
|
16
19
|
|
17
20
|
it 'does not push duplicate messages when configured for unique only' do
|
@@ -25,5 +28,24 @@ class TestClient < MiniTest::Unit::TestCase
|
|
25
28
|
10.times { Sidekiq::Client.push('class' => QueueWorker, 'args' => [1, 2]) }
|
26
29
|
assert_equal 10, Sidekiq.redis {|c| c.llen("queue:customqueue") }
|
27
30
|
end
|
31
|
+
|
32
|
+
# TODO: If anyone know of a better way to check that the expiration for scheduled
|
33
|
+
# jobs are set around the same time as the scheduled job itself feel free to improve.
|
34
|
+
it 'expires the payload_hash when a scheduled job is scheduled at' do
|
35
|
+
require 'active_support/all'
|
36
|
+
QueueWorker.sidekiq_options :unique => true
|
37
|
+
|
38
|
+
at = 15.minutes.from_now
|
39
|
+
expected_expires_at = (Time.at(at) - Time.now.utc).to_f
|
40
|
+
|
41
|
+
QueueWorker.perform_in(at, 'mike')
|
42
|
+
payload_hash = Digest::MD5.hexdigest(Sidekiq.dump_json(['mike']))
|
43
|
+
|
44
|
+
# deconstruct this into a time format we can use to get a decent delta for
|
45
|
+
actual_expires_at = Sidekiq.redis {|c| c.ttl(payload_hash).to_f / 24 / 60 / 60 }
|
46
|
+
|
47
|
+
assert_in_delta expected_expires_at, actual_expires_at, 0.05
|
48
|
+
|
49
|
+
end
|
28
50
|
end
|
29
51
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-unique-jobs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -160,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
160
160
|
version: '0'
|
161
161
|
segments:
|
162
162
|
- 0
|
163
|
-
hash:
|
163
|
+
hash: -556960269690268684
|
164
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
165
|
none: false
|
166
166
|
requirements:
|
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
169
|
version: '0'
|
170
170
|
segments:
|
171
171
|
- 0
|
172
|
-
hash:
|
172
|
+
hash: -556960269690268684
|
173
173
|
requirements: []
|
174
174
|
rubyforge_project:
|
175
175
|
rubygems_version: 1.8.24
|
@@ -179,3 +179,4 @@ summary: The unique jobs that were removed from sidekiq
|
|
179
179
|
test_files:
|
180
180
|
- test/helper.rb
|
181
181
|
- test/lib/sidekiq/test_client.rb
|
182
|
+
has_rdoc:
|