sidekiq-unique-jobs 5.0.8 → 5.0.9
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +2 -2
- data/Rakefile +0 -1
- data/lib/sidekiq-unique-jobs.rb +1 -1
- data/lib/sidekiq_unique_jobs/core_ext.rb +16 -0
- data/lib/sidekiq_unique_jobs/options_with_fallback.rb +20 -3
- data/lib/sidekiq_unique_jobs/script_mock.rb +3 -1
- data/lib/sidekiq_unique_jobs/testing.rb +2 -2
- data/lib/sidekiq_unique_jobs/util.rb +7 -1
- data/lib/sidekiq_unique_jobs/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7238f6463cf70d3aa15dfa9f13222bfd095be565
|
4
|
+
data.tar.gz: 296c50852200e0fe7f17bef756aa4ed339764c9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3b1d70cb51300b90ed59fc873af2a1722b1775aaea2b077ae9df7b606ebee594bbd8b6ef75611b0ad90ecf7bad7968dd7e05fbbf3c32ffc8bdaac707451f403
|
7
|
+
data.tar.gz: a1ab235a39e48aae97df51df2f912b832008ace438903eca2f386221c7c32d02a361af2f8eadf33aa4bd5702db1d6a094e7c522e1a00d864c5c334302b2344af
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## v5.0.9
|
2
|
+
- [#229](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/#229) Use HSCAN for expiring keys
|
3
|
+
- [#232](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/#232) Fix testing helper
|
4
|
+
|
5
|
+
## v5.0.8
|
6
|
+
- Fixes [#220](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/220)
|
7
|
+
|
1
8
|
## v5.0.7
|
2
9
|
- Fixes [#218](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/218)
|
3
10
|
|
data/README.md
CHANGED
@@ -161,8 +161,8 @@ class UniqueJobWithFilterMethod
|
|
161
161
|
sidekiq_options unique: :until_and_while_executing,
|
162
162
|
unique_args: :unique_args
|
163
163
|
|
164
|
-
def self.unique_args(
|
165
|
-
[
|
164
|
+
def self.unique_args(args)
|
165
|
+
[ args[0], args[2][:type] ]
|
166
166
|
end
|
167
167
|
|
168
168
|
...
|
data/Rakefile
CHANGED
data/lib/sidekiq-unique-jobs.rb
CHANGED
@@ -58,7 +58,7 @@ module SidekiqUniqueJobs
|
|
58
58
|
# failing back to the original argument.
|
59
59
|
def worker_class_constantize(worker_class)
|
60
60
|
return worker_class unless worker_class.is_a?(String)
|
61
|
-
worker_class
|
61
|
+
Object.const_get(worker_class)
|
62
62
|
rescue NameError
|
63
63
|
worker_class
|
64
64
|
end
|
@@ -12,6 +12,22 @@ rescue LoadError
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
unless {}.respond_to?(:stringify_keys)
|
16
|
+
def stringify_keys
|
17
|
+
transform_keys(&:to_s)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
unless {}.respond_to?(:transform_keys)
|
22
|
+
def transform_keys
|
23
|
+
result = {}
|
24
|
+
each_key do |key|
|
25
|
+
result[yield(key)] = self[key]
|
26
|
+
end
|
27
|
+
result
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
15
31
|
unless {}.respond_to?(:slice!)
|
16
32
|
def slice!(*keys)
|
17
33
|
keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true)
|
@@ -3,8 +3,7 @@
|
|
3
3
|
module SidekiqUniqueJobs
|
4
4
|
module OptionsWithFallback
|
5
5
|
def self.included(base)
|
6
|
-
base.
|
7
|
-
base.lock_cache ||= {}
|
6
|
+
base.send(:extend, SidekiqUniqueJobs::OptionsWithFallback::ClassMethods)
|
8
7
|
end
|
9
8
|
|
10
9
|
def unique_enabled?
|
@@ -24,7 +23,7 @@ module SidekiqUniqueJobs
|
|
24
23
|
end
|
25
24
|
|
26
25
|
def lock_class
|
27
|
-
lock_cache[unique_lock.to_sym] ||= "SidekiqUniqueJobs::Lock::#{unique_lock.to_s.classify}"
|
26
|
+
lock_cache[unique_lock.to_sym] ||= Object.const_get("SidekiqUniqueJobs::Lock::#{unique_lock.to_s.classify}")
|
28
27
|
end
|
29
28
|
|
30
29
|
def unique_lock
|
@@ -47,11 +46,29 @@ module SidekiqUniqueJobs
|
|
47
46
|
hash[key]
|
48
47
|
end
|
49
48
|
|
49
|
+
def lock_cache
|
50
|
+
self.class.lock_cache
|
51
|
+
end
|
52
|
+
|
53
|
+
def lock_cache=(obj)
|
54
|
+
self.class.lock_cache = obj
|
55
|
+
end
|
56
|
+
|
50
57
|
def options
|
51
58
|
@options ||= worker_class.get_sidekiq_options if worker_class.respond_to?(:get_sidekiq_options)
|
52
59
|
@options ||= Sidekiq.default_worker_options
|
53
60
|
@options ||= {}
|
54
61
|
@options &&= @options.stringify_keys
|
55
62
|
end
|
63
|
+
|
64
|
+
module ClassMethods
|
65
|
+
def lock_cache
|
66
|
+
@lock_cache ||= {}
|
67
|
+
end
|
68
|
+
|
69
|
+
def lock_cache=(obj)
|
70
|
+
@lock_cache = obj
|
71
|
+
end
|
72
|
+
end
|
56
73
|
end
|
57
74
|
end
|
@@ -22,9 +22,10 @@ module SidekiqUniqueJobs
|
|
22
22
|
stored_jid = conn.get(unique_key)
|
23
23
|
|
24
24
|
return (stored_jid == job_id) ? 1 : 0 if stored_jid
|
25
|
-
|
26
25
|
return 0 unless conn.set(unique_key, job_id, nx: true, ex: expires)
|
26
|
+
|
27
27
|
conn.hsetnx(SidekiqUniqueJobs::HASH_KEY, job_id, unique_key)
|
28
|
+
|
28
29
|
return 1
|
29
30
|
end
|
30
31
|
end
|
@@ -40,6 +41,7 @@ module SidekiqUniqueJobs
|
|
40
41
|
|
41
42
|
conn.del(unique_key)
|
42
43
|
conn.hdel(SidekiqUniqueJobs::HASH_KEY, job_id)
|
44
|
+
|
43
45
|
return 1
|
44
46
|
end
|
45
47
|
end
|
@@ -46,8 +46,8 @@ module SidekiqUniqueJobs
|
|
46
46
|
worker_class = SidekiqUniqueJobs.worker_class_constantize(worker_class)
|
47
47
|
|
48
48
|
if Sidekiq::Testing.inline?
|
49
|
-
|
50
|
-
|
49
|
+
call_real(worker_class, item, queue, redis_pool) do
|
50
|
+
_server.call(worker_class.new, item, queue, redis_pool) do
|
51
51
|
yield
|
52
52
|
end
|
53
53
|
end
|
@@ -6,6 +6,7 @@ module SidekiqUniqueJobs
|
|
6
6
|
DEFAULT_COUNT ||= 1_000
|
7
7
|
KEYS_METHOD ||= 'keys'
|
8
8
|
SCAN_METHOD ||= 'scan'
|
9
|
+
EXPIRE_BATCH_SIZE ||= 100
|
9
10
|
|
10
11
|
module_function
|
11
12
|
|
@@ -43,11 +44,16 @@ module SidekiqUniqueJobs
|
|
43
44
|
def expire
|
44
45
|
removed_keys = {}
|
45
46
|
connection do |conn|
|
46
|
-
|
47
|
+
cursor = '0'
|
48
|
+
cursor, jobs = conn.hscan(SidekiqUniqueJobs::HASH_KEY, [cursor, 'MATCH', '*', 'COUNT', EXPIRE_BATCH_SIZE])
|
49
|
+
jobs.each do |job_array|
|
50
|
+
jid, unique_key = job_array
|
47
51
|
next if conn.get(unique_key)
|
48
52
|
conn.hdel(SidekiqUniqueJobs::HASH_KEY, jid)
|
49
53
|
removed_keys[jid] = unique_key
|
50
54
|
end
|
55
|
+
|
56
|
+
break if cursor == '0'
|
51
57
|
end
|
52
58
|
removed_keys
|
53
59
|
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: 5.0.
|
4
|
+
version: 5.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikael Henriksson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -217,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
217
|
version: '0'
|
218
218
|
requirements: []
|
219
219
|
rubyforge_project:
|
220
|
-
rubygems_version: 2.6.
|
220
|
+
rubygems_version: 2.6.12
|
221
221
|
signing_key:
|
222
222
|
specification_version: 4
|
223
223
|
summary: Uniqueness for Sidekiq Jobs
|