sidekiq-unique-jobs 4.0.16 → 4.0.17
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/README.md +3 -3
- data/bin/bench +1 -1
- data/circle.yml +6 -3
- data/lib/sidekiq_unique_jobs/client/middleware.rb +2 -2
- data/lib/sidekiq_unique_jobs/lock/until_executed.rb +2 -2
- data/lib/sidekiq_unique_jobs/version.rb +1 -1
- data/redis/{aquire_lock.lua → acquire_lock.lua} +0 -0
- data/redis/release_lock.lua +3 -4
- data/spec/lib/sidekiq_unique_jobs/scripts_spec.rb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed1a8ffb2ff6f320e5304d4d205b8e1b0d45e98b
|
4
|
+
data.tar.gz: a65deff79a35909d35259361b430211bb30fb65a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e88464e143a66dd207f509b1739bb7d838f08131694ce3c7dca2d0eae16d10e751c24731a7e41f1a1ea68085c9850326a16685e6c254726d778cbf89bdbf13f
|
7
|
+
data.tar.gz: 90416313c946c6bbf96cfe2c6399714d2720254755db8d4505c24bfd6e4f7e9aac364487c6dc5ffba9cd64947bfd9cbee9472ff9d197606395b05d9871200165
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
# SidekiqUniqueJobs [![Join the chat at https://gitter.im/mhenrixon/sidekiq-unique-jobs](https://badges.gitter.im/mhenrixon/sidekiq-unique-jobs.svg)](https://gitter.im/
|
2
|
-
xon/sidekiq-unique-jobs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/mhenrixon/sidekiq-unique-jobs.png?branch=master)](https://travis-ci.org/mhenrixon/sidekiq-unique-jobs) [![Code Climate](https://codeclimate.com/github/mhenrixon/sidekiq-unique-jobs.png)](https://codeclimate.com/github/mhenrixon/sidekiq-unique-jobs) [![Test Coverage](https://codeclimate.com/github/mhenrixon/sidekiq-unique-jobs/badges/coverage.svg)](https://codeclimate.com/github/mhenrixon/sidekiq-unique-jobs/coverage)
|
1
|
+
# SidekiqUniqueJobs [![Join the chat at https://gitter.im/mhenrixon/sidekiq-unique-jobs](https://badges.gitter.im/mhenrixon/sidekiq-unique-jobs.svg)](https://gitter.im/mhenrixon/sidekiq-unique-jobs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/mhenrixon/sidekiq-unique-jobs.png?branch=master)](https://travis-ci.org/mhenrixon/sidekiq-unique-jobs) [![Code Climate](https://codeclimate.com/github/mhenrixon/sidekiq-unique-jobs.png)](https://codeclimate.com/github/mhenrixon/sidekiq-unique-jobs) [![Test Coverage](https://codeclimate.com/github/mhenrixon/sidekiq-unique-jobs/badges/coverage.svg)](https://codeclimate.com/github/mhenrixon/sidekiq-unique-jobs/coverage)
|
3
2
|
|
4
3
|
The missing unique jobs for sidekiq
|
5
4
|
|
6
5
|
## Requirements
|
7
6
|
|
7
|
+
|
8
8
|
See https://github.com/mperham/sidekiq#requirements for what is required. Starting from 3.0.13 only sidekiq 3 is supported and support for MRI 1.9 is dropped (it might work but won't be worked on)
|
9
9
|
|
10
10
|
### Version 4 Upgrade instructions
|
@@ -81,7 +81,7 @@ The difference is that this job has two types of uniqueness:
|
|
81
81
|
1. It is unique until execution
|
82
82
|
2. It is unique while executing
|
83
83
|
|
84
|
-
That means it locks for any job with the same arguments to be persisted into redis and just like you would expect it will only ever allow one job of the same unique arguments to run at any given time but as soon as the runtime lock has been
|
84
|
+
That means it locks for any job with the same arguments to be persisted into redis and just like you would expect it will only ever allow one job of the same unique arguments to run at any given time but as soon as the runtime lock has been acquired the schedule/async lock is released.
|
85
85
|
|
86
86
|
### Uniqueness Scope
|
87
87
|
|
data/bin/bench
CHANGED
@@ -13,7 +13,7 @@ ITERATIONS ||= 10_000
|
|
13
13
|
Benchmark.ips do |x|
|
14
14
|
x.config(time: 5, warmup: 2)
|
15
15
|
x.report('new_shit') do |_times|
|
16
|
-
SidekiqUniqueJobs::Scripts.call(:
|
16
|
+
SidekiqUniqueJobs::Scripts.call(:acquire_lock, nil, keys: [SecureRandom.hex], argv: [SecureRandom.hex])
|
17
17
|
end
|
18
18
|
x.compare!
|
19
19
|
end
|
data/circle.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
machine:
|
2
2
|
ruby:
|
3
3
|
version:
|
4
|
-
2.
|
4
|
+
2.3.0
|
5
5
|
java:
|
6
6
|
version: oraclejdk8
|
7
7
|
environment:
|
@@ -14,19 +14,21 @@ dependencies:
|
|
14
14
|
- rvm install rbx-2
|
15
15
|
- rvm install 2.0.0
|
16
16
|
- rvm install 2.1.7
|
17
|
+
- rvm install 2.2.3
|
17
18
|
override:
|
18
19
|
- rvm-exec jruby-9.0.0.0 bundle install
|
19
20
|
- rvm-exec jruby-1.7 bundle install
|
20
21
|
- rvm-exec rbx-2 bundle install
|
21
22
|
- rvm-exec 2.0.0 bundle install
|
22
|
-
- rvm-exec 2.1.
|
23
|
-
- rvm-exec 2.2.
|
23
|
+
- rvm-exec 2.1.8 bundle install
|
24
|
+
- rvm-exec 2.2.4 bundle install
|
24
25
|
- rvm-exec jruby-9.0.0.0 bundle exec appraisal install
|
25
26
|
- rvm-exec jruby-1.7 bundle exec appraisal install
|
26
27
|
- rvm-exec rbx-2 bundle exec appraisal install
|
27
28
|
- rvm-exec 2.0.0 bundle exec appraisal install
|
28
29
|
- rvm-exec 2.1.7 bundle exec appraisal install
|
29
30
|
- rvm-exec 2.2.3 bundle exec appraisal install
|
31
|
+
- rvm-exec 2.3.0 bundle exec appraisal install
|
30
32
|
|
31
33
|
test:
|
32
34
|
override:
|
@@ -36,3 +38,4 @@ test:
|
|
36
38
|
- rvm-exec 2.0.0 bundle exec appraisal rspec
|
37
39
|
- rvm-exec 2.1.7 bundle exec appraisal rspec
|
38
40
|
- rvm-exec 2.2.3 bundle exec appraisal rspec
|
41
|
+
- rvm-exec 2.3.0 bundle exec appraisal rspec
|
@@ -23,10 +23,10 @@ module SidekiqUniqueJobs
|
|
23
23
|
attr_reader :item, :worker_class, :redis_pool, :queue
|
24
24
|
|
25
25
|
def disabled_or_successfully_locked?
|
26
|
-
unique_disabled? ||
|
26
|
+
unique_disabled? || acquire_lock
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
29
|
+
def acquire_lock
|
30
30
|
return true unless lock.respond_to?(:lock)
|
31
31
|
locked = lock.lock(:client)
|
32
32
|
warn_about_duplicate(item) unless locked
|
@@ -37,7 +37,7 @@ module SidekiqUniqueJobs
|
|
37
37
|
raise ArgumentError, "#{scope} middleware can't #{__method__} #{unique_key}"
|
38
38
|
end
|
39
39
|
|
40
|
-
result = Scripts.call(:
|
40
|
+
result = Scripts.call(:acquire_lock, redis_pool,
|
41
41
|
keys: [unique_key],
|
42
42
|
argv: [item[JID_KEY], max_lock_time])
|
43
43
|
case result
|
@@ -45,7 +45,7 @@ module SidekiqUniqueJobs
|
|
45
45
|
logger.debug { "successfully locked #{unique_key} for #{max_lock_time} seconds" }
|
46
46
|
true
|
47
47
|
when 0
|
48
|
-
logger.debug { "failed to
|
48
|
+
logger.debug { "failed to acquire lock for #{unique_key}" }
|
49
49
|
false
|
50
50
|
else
|
51
51
|
raise "#{__method__} returned an unexpected value (#{result})"
|
File without changes
|
data/redis/release_lock.lua
CHANGED
@@ -4,10 +4,9 @@ local stored_jid = redis.pcall('get', unique_key)
|
|
4
4
|
|
5
5
|
if stored_jid then
|
6
6
|
if stored_jid == job_id or stored_jid == '2' then
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
7
|
+
redis.pcall('del', unique_key)
|
8
|
+
redis.pcall('hdel', 'uniquejobs', job_id)
|
9
|
+
return 1
|
11
10
|
else
|
12
11
|
return 0
|
13
12
|
end
|
@@ -24,14 +24,14 @@ 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(:
|
27
|
+
subject.call(:acquire_lock, nil, keys: [key], argv: [jid, seconds])
|
28
28
|
end
|
29
29
|
|
30
30
|
def unlock(key = UNIQUE_KEY, jid = JID)
|
31
31
|
subject.call(:release_lock, nil, keys: [key], argv: [jid])
|
32
32
|
end
|
33
33
|
|
34
|
-
describe '.
|
34
|
+
describe '.acquire_lock' do
|
35
35
|
context 'when job is unique' do
|
36
36
|
specify { expect(lock_for).to eq(1) }
|
37
37
|
specify do
|
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.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikael Henriksson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02
|
11
|
+
date: 2016-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -230,7 +230,7 @@ files:
|
|
230
230
|
- rails_example/simple.ru
|
231
231
|
- rails_example/vendor/assets/javascripts/.keep
|
232
232
|
- rails_example/vendor/assets/stylesheets/.keep
|
233
|
-
- redis/
|
233
|
+
- redis/acquire_lock.lua
|
234
234
|
- redis/release_lock.lua
|
235
235
|
- redis/synchronize.lua
|
236
236
|
- sidekiq-unique-jobs.gemspec
|
@@ -304,7 +304,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
304
304
|
version: '0'
|
305
305
|
requirements: []
|
306
306
|
rubyforge_project:
|
307
|
-
rubygems_version: 2.5.
|
307
|
+
rubygems_version: 2.4.5.1
|
308
308
|
signing_key:
|
309
309
|
specification_version: 4
|
310
310
|
summary: The unique jobs that were removed from sidekiq
|