sidekiq-unique-jobs 7.1.1 → 7.1.6
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/CHANGELOG.md +54 -0
- data/README.md +590 -540
- data/lib/sidekiq_unique_jobs/config.rb +2 -2
- data/lib/sidekiq_unique_jobs/lock/base_lock.rb +1 -0
- data/lib/sidekiq_unique_jobs/lock_config.rb +3 -3
- data/lib/sidekiq_unique_jobs/locksmith.rb +4 -1
- data/lib/sidekiq_unique_jobs/sidekiq_unique_ext.rb +35 -13
- data/lib/sidekiq_unique_jobs/timing.rb +1 -1
- data/lib/sidekiq_unique_jobs/version.rb +1 -1
- metadata +3 -3
@@ -116,8 +116,8 @@ module SidekiqUniqueJobs
|
|
116
116
|
REAPER_RESURRECTOR_INTERVAL = 3600
|
117
117
|
|
118
118
|
#
|
119
|
-
# @return [
|
120
|
-
REAPER_RESURRECTOR_ENABLED =
|
119
|
+
# @return [false] enable reaper resurrector
|
120
|
+
REAPER_RESURRECTOR_ENABLED = false
|
121
121
|
|
122
122
|
#
|
123
123
|
# @return [false] while useful it also adds overhead so disable lock_info by default
|
@@ -59,8 +59,8 @@ module SidekiqUniqueJobs
|
|
59
59
|
def initialize(job_hash = {})
|
60
60
|
@type = job_hash[LOCK]&.to_sym
|
61
61
|
@worker = SidekiqUniqueJobs.safe_constantize(job_hash[CLASS])
|
62
|
-
@limit = job_hash.fetch(LOCK_LIMIT, 1)
|
63
|
-
@timeout = job_hash.fetch(LOCK_TIMEOUT, 0)
|
62
|
+
@limit = job_hash.fetch(LOCK_LIMIT, 1)&.to_i
|
63
|
+
@timeout = job_hash.fetch(LOCK_TIMEOUT, 0)&.to_i
|
64
64
|
@ttl = job_hash.fetch(LOCK_TTL) { job_hash.fetch(LOCK_EXPIRATION, nil) }.to_i
|
65
65
|
@pttl = ttl * 1_000
|
66
66
|
@lock_info = job_hash.fetch(LOCK_INFO) { SidekiqUniqueJobs.config.lock_info }
|
@@ -79,7 +79,7 @@ module SidekiqUniqueJobs
|
|
79
79
|
# Indicate if timeout was set
|
80
80
|
#
|
81
81
|
#
|
82
|
-
# @return [true,
|
82
|
+
# @return [true,false]
|
83
83
|
#
|
84
84
|
def wait_for_lock?
|
85
85
|
timeout.nil? || timeout.positive?
|
@@ -179,6 +179,9 @@ module SidekiqUniqueJobs
|
|
179
179
|
#
|
180
180
|
# Used to reduce some duplication from the two methods
|
181
181
|
#
|
182
|
+
# @see lock
|
183
|
+
# @see execute
|
184
|
+
#
|
182
185
|
# @param [Sidekiq::RedisConnection, ConnectionPool] conn the redis connection
|
183
186
|
# @param [Method] primed_method reference to the method to use for getting a primed token
|
184
187
|
#
|
@@ -238,7 +241,7 @@ module SidekiqUniqueJobs
|
|
238
241
|
def primed_async(conn, wait = nil, &block)
|
239
242
|
primed_jid = Concurrent::Promises
|
240
243
|
.future(conn) { |red_con| pop_queued(red_con, wait) }
|
241
|
-
.value(add_drift(wait || config.
|
244
|
+
.value(add_drift(wait || config.timeout))
|
242
245
|
|
243
246
|
handle_primed(primed_jid, &block)
|
244
247
|
end
|
@@ -68,24 +68,46 @@ module Sidekiq
|
|
68
68
|
prepend UniqueExtension
|
69
69
|
end
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
# Provides extensions for unlocking jobs that are removed and deleted
|
75
|
-
#
|
76
|
-
# @author Mikael Henriksson <mikael@mhenrixon.com>
|
77
|
-
#
|
78
|
-
module UniqueExtension
|
71
|
+
if Sidekiq.const_defined?("JobRecord")
|
72
|
+
# See Sidekiq::Api
|
73
|
+
class JobRecord
|
79
74
|
#
|
80
|
-
#
|
75
|
+
# Provides extensions for unlocking jobs that are removed and deleted
|
81
76
|
#
|
82
|
-
|
83
|
-
|
84
|
-
|
77
|
+
# @author Mikael Henriksson <mikael@mhenrixon.com>
|
78
|
+
#
|
79
|
+
module UniqueExtension
|
80
|
+
#
|
81
|
+
# Wraps the original method to ensure locks for the job are deleted
|
82
|
+
#
|
83
|
+
def delete
|
84
|
+
SidekiqUniqueJobs::Unlockable.delete!(item)
|
85
|
+
super
|
86
|
+
end
|
85
87
|
end
|
88
|
+
|
89
|
+
prepend UniqueExtension
|
86
90
|
end
|
91
|
+
else
|
92
|
+
# See Sidekiq::Api
|
93
|
+
class Job
|
94
|
+
#
|
95
|
+
# Provides extensions for unlocking jobs that are removed and deleted
|
96
|
+
#
|
97
|
+
# @author Mikael Henriksson <mikael@mhenrixon.com>
|
98
|
+
#
|
99
|
+
module UniqueExtension
|
100
|
+
#
|
101
|
+
# Wraps the original method to ensure locks for the job are deleted
|
102
|
+
#
|
103
|
+
def delete
|
104
|
+
SidekiqUniqueJobs::Unlockable.delete!(item)
|
105
|
+
super
|
106
|
+
end
|
107
|
+
end
|
87
108
|
|
88
|
-
|
109
|
+
prepend UniqueExtension
|
110
|
+
end
|
89
111
|
end
|
90
112
|
|
91
113
|
# See Sidekiq::Api
|
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: 7.1.
|
4
|
+
version: 7.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikael Henriksson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: brpoplpush-redis_script
|
@@ -261,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
261
261
|
- !ruby/object:Gem::Version
|
262
262
|
version: '0'
|
263
263
|
requirements: []
|
264
|
-
rubygems_version: 3.2.
|
264
|
+
rubygems_version: 3.2.27
|
265
265
|
signing_key:
|
266
266
|
specification_version: 4
|
267
267
|
summary: Sidekiq middleware that prevents duplicates jobs
|