sidekiq-unique-jobs 7.1.8 → 7.1.29
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 +283 -2
- data/README.md +17 -14
- data/lib/sidekiq_unique_jobs/batch_delete.rb +7 -6
- data/lib/sidekiq_unique_jobs/changelog.rb +3 -3
- data/lib/sidekiq_unique_jobs/cli.rb +33 -8
- data/lib/sidekiq_unique_jobs/config.rb +5 -0
- data/lib/sidekiq_unique_jobs/constants.rb +1 -0
- data/lib/sidekiq_unique_jobs/digests.rb +5 -5
- data/lib/sidekiq_unique_jobs/exceptions.rb +3 -3
- data/lib/sidekiq_unique_jobs/expiring_digests.rb +14 -0
- data/lib/sidekiq_unique_jobs/key.rb +13 -8
- data/lib/sidekiq_unique_jobs/lock/until_executed.rb +5 -1
- data/lib/sidekiq_unique_jobs/lock/until_executing.rb +4 -0
- data/lib/sidekiq_unique_jobs/lock/until_expired.rb +3 -1
- data/lib/sidekiq_unique_jobs/lock/while_executing.rb +4 -1
- data/lib/sidekiq_unique_jobs/lock.rb +27 -10
- data/lib/sidekiq_unique_jobs/lock_args.rb +19 -15
- data/lib/sidekiq_unique_jobs/lock_config.rb +6 -6
- data/lib/sidekiq_unique_jobs/lock_digest.rb +7 -7
- data/lib/sidekiq_unique_jobs/lock_info.rb +2 -2
- data/lib/sidekiq_unique_jobs/lock_timeout.rb +4 -4
- data/lib/sidekiq_unique_jobs/lock_ttl.rb +4 -4
- data/lib/sidekiq_unique_jobs/locksmith.rb +30 -9
- data/lib/sidekiq_unique_jobs/logging.rb +14 -0
- data/lib/sidekiq_unique_jobs/lua/lock.lua +15 -9
- data/lib/sidekiq_unique_jobs/lua/lock_until_expired.lua +92 -0
- data/lib/sidekiq_unique_jobs/lua/reap_orphans.lua +31 -3
- data/lib/sidekiq_unique_jobs/lua/shared/_common.lua +1 -1
- data/lib/sidekiq_unique_jobs/lua/unlock.lua +11 -7
- data/lib/sidekiq_unique_jobs/middleware/client.rb +2 -0
- data/lib/sidekiq_unique_jobs/middleware/server.rb +2 -0
- data/lib/sidekiq_unique_jobs/middleware.rb +4 -4
- data/lib/sidekiq_unique_jobs/on_conflict/reject.rb +4 -4
- data/lib/sidekiq_unique_jobs/on_conflict/reschedule.rb +3 -3
- data/lib/sidekiq_unique_jobs/options_with_fallback.rb +3 -3
- data/lib/sidekiq_unique_jobs/orphans/lua_reaper.rb +1 -1
- data/lib/sidekiq_unique_jobs/orphans/manager.rb +3 -10
- data/lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb +96 -13
- data/lib/sidekiq_unique_jobs/redis/string.rb +3 -1
- data/lib/sidekiq_unique_jobs/sidekiq_unique_ext.rb +1 -1
- data/lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb +10 -0
- data/lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb +40 -21
- data/lib/sidekiq_unique_jobs/testing.rb +53 -21
- data/lib/sidekiq_unique_jobs/timer_task.rb +266 -45
- data/lib/sidekiq_unique_jobs/timing.rb +1 -1
- data/lib/sidekiq_unique_jobs/upgrade_locks.rb +6 -6
- data/lib/sidekiq_unique_jobs/version.rb +1 -1
- data/lib/sidekiq_unique_jobs/web/helpers.rb +11 -1
- data/lib/sidekiq_unique_jobs/web.rb +22 -3
- data/lib/sidekiq_unique_jobs.rb +1 -0
- data/lib/tasks/changelog.rake +1 -1
- metadata +23 -11
@@ -1,25 +1,279 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "concurrent/collection/copy_on_notify_observer_set"
|
4
|
+
require "concurrent/concern/dereferenceable"
|
5
|
+
require "concurrent/concern/observable"
|
6
|
+
require "concurrent/atomic/atomic_boolean"
|
7
|
+
require "concurrent/executor/executor_service"
|
8
|
+
require "concurrent/executor/ruby_executor_service"
|
9
|
+
require "concurrent/executor/safe_task_executor"
|
10
|
+
require "concurrent/scheduled_task"
|
11
|
+
|
3
12
|
module SidekiqUniqueJobs
|
4
|
-
#
|
13
|
+
# A very common concurrency pattern is to run a thread that performs a task at
|
14
|
+
# regular intervals. The thread that performs the task sleeps for the given
|
15
|
+
# interval then wakes up and performs the task. Lather, rinse, repeat... This
|
16
|
+
# pattern causes two problems. First, it is difficult to test the business
|
17
|
+
# logic of the task because the task itself is tightly coupled with the
|
18
|
+
# concurrency logic. Second, an exception raised while performing the task can
|
19
|
+
# cause the entire thread to abend. In a long-running application where the
|
20
|
+
# task thread is intended to run for days/weeks/years a crashed task thread
|
21
|
+
# can pose a significant problem. `TimerTask` alleviates both problems.
|
22
|
+
#
|
23
|
+
# When a `TimerTask` is launched it starts a thread for monitoring the
|
24
|
+
# execution interval. The `TimerTask` thread does not perform the task,
|
25
|
+
# however. Instead, the TimerTask launches the task on a separate thread.
|
26
|
+
# Should the task experience an unrecoverable crash only the task thread will
|
27
|
+
# crash. This makes the `TimerTask` very fault tolerant. Additionally, the
|
28
|
+
# `TimerTask` thread can respond to the success or failure of the task,
|
29
|
+
# performing logging or ancillary operations.
|
30
|
+
#
|
31
|
+
# One other advantage of `TimerTask` is that it forces the business logic to
|
32
|
+
# be completely decoupled from the concurrency logic. The business logic can
|
33
|
+
# be tested separately then passed to the `TimerTask` for scheduling and
|
34
|
+
# running.
|
35
|
+
#
|
36
|
+
# In some cases it may be necessary for a `TimerTask` to affect its own
|
37
|
+
# execution cycle. To facilitate this, a reference to the TimerTask instance
|
38
|
+
# is passed as an argument to the provided block every time the task is
|
39
|
+
# executed.
|
40
|
+
#
|
41
|
+
# The `TimerTask` class includes the `Dereferenceable` mixin module so the
|
42
|
+
# result of the last execution is always available via the `#value` method.
|
43
|
+
# Dereferencing options can be passed to the `TimerTask` during construction or
|
44
|
+
# at any later time using the `#set_deref_options` method.
|
45
|
+
#
|
46
|
+
# `TimerTask` supports notification through the Ruby standard library
|
47
|
+
# {http://ruby-doc.org/stdlib-2.0/libdoc/observer/rdoc/Observable.html
|
48
|
+
# Observable} module. On execution the `TimerTask` will notify the observers
|
49
|
+
# with three arguments: time of execution, the result of the block (or nil on
|
50
|
+
# failure), and any raised exceptions (or nil on success).
|
51
|
+
#
|
52
|
+
# @!macro copy_options
|
53
|
+
#
|
54
|
+
# @example Basic usage
|
55
|
+
# task = Concurrent::TimerTask.new{ puts 'Boom!' }
|
56
|
+
# task.execute
|
57
|
+
#
|
58
|
+
# task.execution_interval #=> 60 (default)
|
59
|
+
#
|
60
|
+
# # wait 60 seconds...
|
61
|
+
# #=> 'Boom!'
|
62
|
+
#
|
63
|
+
# task.shutdown #=> true
|
64
|
+
#
|
65
|
+
# @example Configuring `:execution_interval`
|
66
|
+
# task = Concurrent::TimerTask.new(execution_interval: 5) do
|
67
|
+
# puts 'Boom!'
|
68
|
+
# end
|
69
|
+
#
|
70
|
+
# task.execution_interval #=> 5
|
71
|
+
#
|
72
|
+
# @example Immediate execution with `:run_now`
|
73
|
+
# task = Concurrent::TimerTask.new(run_now: true){ puts 'Boom!' }
|
74
|
+
# task.execute
|
75
|
+
#
|
76
|
+
# #=> 'Boom!'
|
77
|
+
#
|
78
|
+
# @example Last `#value` and `Dereferenceable` mixin
|
79
|
+
# task = Concurrent::TimerTask.new(
|
80
|
+
# dup_on_deref: true,
|
81
|
+
# execution_interval: 5
|
82
|
+
# ){ Time.now }
|
5
83
|
#
|
6
|
-
|
84
|
+
# task.execute
|
85
|
+
# Time.now #=> 2013-11-07 18:06:50 -0500
|
86
|
+
# sleep(10)
|
87
|
+
# task.value #=> 2013-11-07 18:06:55 -0500
|
88
|
+
#
|
89
|
+
# @example Controlling execution from within the block
|
90
|
+
# timer_task = Concurrent::TimerTask.new(execution_interval: 1) do |task|
|
91
|
+
# task.execution_interval.times{ print 'Boom! ' }
|
92
|
+
# print "\n"
|
93
|
+
# task.execution_interval += 1
|
94
|
+
# if task.execution_interval > 5
|
95
|
+
# puts 'Stopping...'
|
96
|
+
# task.shutdown
|
97
|
+
# end
|
98
|
+
# end
|
99
|
+
#
|
100
|
+
# timer_task.execute # blocking call - this task will stop itself
|
101
|
+
# #=> Boom!
|
102
|
+
# #=> Boom! Boom!
|
103
|
+
# #=> Boom! Boom! Boom!
|
104
|
+
# #=> Boom! Boom! Boom! Boom!
|
105
|
+
# #=> Boom! Boom! Boom! Boom! Boom!
|
106
|
+
# #=> Stopping...
|
107
|
+
#
|
108
|
+
# @example Observation
|
109
|
+
# class TaskObserver
|
110
|
+
# def update(time, result, ex)
|
111
|
+
# if result
|
112
|
+
# print "(#{time}) Execution successfully returned #{result}\n"
|
113
|
+
# else
|
114
|
+
# print "(#{time}) Execution failed with error #{ex}\n"
|
115
|
+
# end
|
116
|
+
# end
|
117
|
+
# end
|
118
|
+
#
|
119
|
+
# task = Concurrent::TimerTask.new(execution_interval: 1){ 42 }
|
120
|
+
# task.add_observer(TaskObserver.new)
|
121
|
+
# task.execute
|
122
|
+
# sleep 4
|
123
|
+
#
|
124
|
+
# #=> (2013-10-13 19:08:58 -0400) Execution successfully returned 42
|
125
|
+
# #=> (2013-10-13 19:08:59 -0400) Execution successfully returned 42
|
126
|
+
# #=> (2013-10-13 19:09:00 -0400) Execution successfully returned 42
|
127
|
+
# task.shutdown
|
128
|
+
#
|
129
|
+
# task = Concurrent::TimerTask.new(execution_interval: 1){ sleep }
|
130
|
+
# task.add_observer(TaskObserver.new)
|
131
|
+
# task.execute
|
132
|
+
#
|
133
|
+
# #=> (2013-10-13 19:07:25 -0400) Execution timed out
|
134
|
+
# #=> (2013-10-13 19:07:27 -0400) Execution timed out
|
135
|
+
# #=> (2013-10-13 19:07:29 -0400) Execution timed out
|
136
|
+
# task.shutdown
|
137
|
+
#
|
138
|
+
# task = Concurrent::TimerTask.new(execution_interval: 1){ raise StandardError }
|
139
|
+
# task.add_observer(TaskObserver.new)
|
140
|
+
# task.execute
|
141
|
+
#
|
142
|
+
# #=> (2013-10-13 19:09:37 -0400) Execution failed with error StandardError
|
143
|
+
# #=> (2013-10-13 19:09:38 -0400) Execution failed with error StandardError
|
144
|
+
# #=> (2013-10-13 19:09:39 -0400) Execution failed with error StandardError
|
145
|
+
# task.shutdown
|
146
|
+
#
|
147
|
+
# @see http://ruby-doc.org/stdlib-2.0/libdoc/observer/rdoc/Observable.html
|
148
|
+
# @see http://docs.oracle.com/javase/7/docs/api/java/util/TimerTask.html
|
149
|
+
class TimerTask < Concurrent::RubyExecutorService
|
150
|
+
include Concurrent::Concern::Dereferenceable
|
151
|
+
include Concurrent::Concern::Observable
|
152
|
+
|
153
|
+
# Default `:execution_interval` in seconds.
|
154
|
+
EXECUTION_INTERVAL = 60
|
155
|
+
|
156
|
+
# Default `:timeout_interval` in seconds.
|
157
|
+
TIMEOUT_INTERVAL = 30
|
158
|
+
|
159
|
+
# Create a new TimerTask with the given task and configuration.
|
160
|
+
#
|
161
|
+
# @!macro timer_task_initialize
|
162
|
+
# @param [Hash] opts the options defining task execution.
|
163
|
+
# @option opts [Integer] :execution_interval number of seconds between
|
164
|
+
# task executions (default: EXECUTION_INTERVAL)
|
165
|
+
# @option opts [Boolean] :run_now Whether to run the task immediately
|
166
|
+
# upon instantiation or to wait until the first # execution_interval
|
167
|
+
# has passed (default: false)
|
168
|
+
#
|
169
|
+
# @!macro deref_options
|
170
|
+
#
|
171
|
+
# @raise ArgumentError when no block is given.
|
172
|
+
#
|
173
|
+
# @yield to the block after :execution_interval seconds have passed since
|
174
|
+
# the last yield
|
175
|
+
# @yieldparam task a reference to the `TimerTask` instance so that the
|
176
|
+
# block can control its own lifecycle. Necessary since `self` will
|
177
|
+
# refer to the execution context of the block rather than the running
|
178
|
+
# `TimerTask`.
|
179
|
+
#
|
180
|
+
# @return [TimerTask] the new `TimerTask`
|
181
|
+
def initialize(opts = {}, &task)
|
182
|
+
raise ArgumentError, "no block given" unless task
|
183
|
+
|
184
|
+
super
|
185
|
+
set_deref_options opts
|
186
|
+
end
|
187
|
+
|
188
|
+
# Is the executor running?
|
189
|
+
#
|
190
|
+
# @return [Boolean] `true` when running, `false` when shutting down or shutdown
|
191
|
+
def running?
|
192
|
+
@running.true?
|
193
|
+
end
|
194
|
+
|
195
|
+
# Execute a previously created `TimerTask`.
|
196
|
+
#
|
197
|
+
# @return [TimerTask] a reference to `self`
|
198
|
+
#
|
199
|
+
# @example Instance and execute in separate steps
|
200
|
+
# task = Concurrent::TimerTask.new(execution_interval: 10){ print "Hello World\n" }
|
201
|
+
# task.running? #=> false
|
202
|
+
# task.execute
|
203
|
+
# task.running? #=> true
|
204
|
+
#
|
205
|
+
# @example Instance and execute in one line
|
206
|
+
# task = Concurrent::TimerTask.new(execution_interval: 10){ print "Hello World\n" }.execute
|
207
|
+
# task.running? #=> true
|
208
|
+
def execute
|
209
|
+
synchronize do
|
210
|
+
if @running.false?
|
211
|
+
@running.make_true
|
212
|
+
schedule_next_task(@run_now ? 0 : @execution_interval)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
self
|
216
|
+
end
|
217
|
+
|
218
|
+
# Create and execute a new `TimerTask`.
|
219
|
+
#
|
220
|
+
# @!macro timer_task_initialize
|
221
|
+
#
|
222
|
+
# @example
|
223
|
+
# task = Concurrent::TimerTask.execute(execution_interval: 10){ print "Hello World\n" }
|
224
|
+
# task.running? #=> true
|
225
|
+
def self.execute(opts = {}, &task)
|
226
|
+
TimerTask.new(opts, &task).execute
|
227
|
+
end
|
228
|
+
|
229
|
+
# @!attribute [rw] execution_interval
|
230
|
+
# @return [Fixnum] Number of seconds after the task completes before the
|
231
|
+
# task is performed again.
|
232
|
+
def execution_interval
|
233
|
+
synchronize { @execution_interval }
|
234
|
+
end
|
235
|
+
|
236
|
+
# @!attribute [rw] execution_interval
|
237
|
+
# @return [Fixnum] Number of seconds after the task completes before the
|
238
|
+
# task is performed again.
|
239
|
+
def execution_interval=(value)
|
240
|
+
raise ArgumentError, "must be greater than zero" if (value = value.to_f) <= 0.0
|
241
|
+
|
242
|
+
synchronize { @execution_interval = value }
|
243
|
+
end
|
244
|
+
|
245
|
+
private :post, :<<
|
246
|
+
|
7
247
|
private
|
8
248
|
|
9
249
|
def ns_initialize(opts, &task)
|
10
250
|
set_deref_options(opts)
|
11
251
|
|
12
252
|
self.execution_interval = opts[:execution] || opts[:execution_interval] || EXECUTION_INTERVAL
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
@
|
17
|
-
@
|
18
|
-
@
|
253
|
+
if opts[:timeout] || opts[:timeout_interval]
|
254
|
+
warn "TimeTask timeouts are now ignored as these were not able to be implemented correctly"
|
255
|
+
end
|
256
|
+
@run_now = opts[:now] || opts[:run_now]
|
257
|
+
@executor = Concurrent::SafeTaskExecutor.new(task)
|
258
|
+
@running = Concurrent::AtomicBoolean.new(false)
|
259
|
+
@value = nil
|
19
260
|
|
20
261
|
self.observers = Concurrent::Collection::CopyOnNotifyObserverSet.new
|
21
262
|
end
|
22
263
|
|
264
|
+
# @!visibility private
|
265
|
+
def ns_shutdown_execution
|
266
|
+
@running.make_false
|
267
|
+
super
|
268
|
+
end
|
269
|
+
|
270
|
+
# @!visibility private
|
271
|
+
def ns_kill_execution
|
272
|
+
@running.make_false
|
273
|
+
super
|
274
|
+
end
|
275
|
+
|
276
|
+
# @!visibility private
|
23
277
|
def schedule_next_task(interval = execution_interval)
|
24
278
|
exec_task = ->(completion) { execute_task(completion) }
|
25
279
|
Concurrent::ScheduledTask.execute(interval, args: [Concurrent::Event.new], &exec_task)
|
@@ -27,52 +281,19 @@ module SidekiqUniqueJobs
|
|
27
281
|
end
|
28
282
|
|
29
283
|
# @!visibility private
|
30
|
-
def execute_task(completion)
|
284
|
+
def execute_task(completion)
|
31
285
|
return nil unless @running.true?
|
32
286
|
|
33
|
-
|
34
|
-
|
35
|
-
Concurrent::ScheduledTask.execute(
|
36
|
-
timeout_interval,
|
37
|
-
args: [completion],
|
38
|
-
&timeout_task
|
39
|
-
)
|
40
|
-
@thread_completed = Concurrent::Event.new
|
41
|
-
|
42
|
-
@value = @reason = nil
|
43
|
-
@executor.post do
|
44
|
-
@value = @task.call(self)
|
45
|
-
rescue Exception => ex # rubocop:disable Lint/RescueException
|
46
|
-
@reason = ex
|
47
|
-
ensure
|
48
|
-
@thread_completed.set
|
49
|
-
end
|
50
|
-
|
51
|
-
@thread_completed.wait
|
52
|
-
|
287
|
+
_success, value, reason = @executor.execute(self)
|
53
288
|
if completion.try?
|
289
|
+
self.value = value
|
54
290
|
schedule_next_task
|
55
291
|
time = Time.now
|
56
292
|
observers.notify_observers do
|
57
|
-
[time, value,
|
293
|
+
[time, self.value, reason]
|
58
294
|
end
|
59
295
|
end
|
60
296
|
nil
|
61
297
|
end
|
62
|
-
|
63
|
-
# @!visibility private
|
64
|
-
def timeout_task(completion)
|
65
|
-
return unless @running.true?
|
66
|
-
return unless completion.try?
|
67
|
-
|
68
|
-
@executor.kill
|
69
|
-
@executor.wait_for_termination
|
70
|
-
@executor = Concurrent::RubySingleThreadExecutor.new
|
71
|
-
|
72
|
-
@thread_completed.set
|
73
|
-
|
74
|
-
schedule_next_task
|
75
|
-
observers.notify_observers(Time.now, nil, Concurrent::TimeoutError.new)
|
76
|
-
end
|
77
298
|
end
|
78
299
|
end
|
@@ -87,9 +87,9 @@ module SidekiqUniqueJobs
|
|
87
87
|
digest = grabbed_key.gsub(":GRABBED", "")
|
88
88
|
locks = conn.hgetall(grabbed_key)
|
89
89
|
|
90
|
-
conn.pipelined do
|
91
|
-
|
92
|
-
|
90
|
+
conn.pipelined do |pipeline|
|
91
|
+
pipeline.hmset(locked_key, *locks.to_a)
|
92
|
+
pipeline.zadd(DIGESTS, locks.values.first, digest)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
@@ -114,11 +114,11 @@ module SidekiqUniqueJobs
|
|
114
114
|
def batch_delete(*keys)
|
115
115
|
return if keys.empty?
|
116
116
|
|
117
|
-
conn.pipelined do
|
117
|
+
conn.pipelined do |pipeline|
|
118
118
|
if VersionCheck.satisfied?(redis_version, ">= 4.0.0")
|
119
|
-
|
119
|
+
pipeline.unlink(*keys)
|
120
120
|
else
|
121
|
-
|
121
|
+
pipeline.del(*keys)
|
122
122
|
end
|
123
123
|
end
|
124
124
|
end
|
@@ -27,7 +27,7 @@ module SidekiqUniqueJobs
|
|
27
27
|
# @return [String] the file contents of the template
|
28
28
|
#
|
29
29
|
def unique_template(name)
|
30
|
-
File.
|
30
|
+
File.read(unique_filename(name))
|
31
31
|
end
|
32
32
|
|
33
33
|
#
|
@@ -51,6 +51,16 @@ module SidekiqUniqueJobs
|
|
51
51
|
@digests ||= SidekiqUniqueJobs::Digests.new
|
52
52
|
end
|
53
53
|
|
54
|
+
#
|
55
|
+
# The collection of digests
|
56
|
+
#
|
57
|
+
#
|
58
|
+
# @return [SidekiqUniqueJobs::ExpiringDigests] the sorted set with expiring digests
|
59
|
+
#
|
60
|
+
def expiring_digests
|
61
|
+
@expiring_digests ||= SidekiqUniqueJobs::ExpiringDigests.new
|
62
|
+
end
|
63
|
+
|
54
64
|
#
|
55
65
|
# The collection of changelog entries
|
56
66
|
#
|
@@ -8,7 +8,7 @@ module SidekiqUniqueJobs
|
|
8
8
|
#
|
9
9
|
# @author Mikael Henriksson <mikael@mhenrixon.com>
|
10
10
|
module Web
|
11
|
-
def self.registered(app) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
11
|
+
def self.registered(app) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
12
12
|
app.helpers do
|
13
13
|
include Web::Helpers
|
14
14
|
end
|
@@ -49,8 +49,25 @@ module SidekiqUniqueJobs
|
|
49
49
|
erb(unique_template(:locks))
|
50
50
|
end
|
51
51
|
|
52
|
+
app.get "/expiring_locks" do
|
53
|
+
@filter = params[:filter] || "*"
|
54
|
+
@filter = "*" if @filter == ""
|
55
|
+
@count = (params[:count] || 100).to_i
|
56
|
+
@current_cursor = params[:cursor]
|
57
|
+
@prev_cursor = params[:prev_cursor]
|
58
|
+
|
59
|
+
@total_size, @next_cursor, @locks = expiring_digests.page(
|
60
|
+
cursor: @current_cursor,
|
61
|
+
pattern: @filter,
|
62
|
+
page_size: @count,
|
63
|
+
)
|
64
|
+
|
65
|
+
erb(unique_template(:locks))
|
66
|
+
end
|
67
|
+
|
52
68
|
app.get "/locks/delete_all" do
|
53
69
|
digests.delete_by_pattern("*", count: digests.count)
|
70
|
+
expiring_digests.delete_by_pattern("*", count: digests.count)
|
54
71
|
redirect_to :locks
|
55
72
|
end
|
56
73
|
|
@@ -63,6 +80,7 @@ module SidekiqUniqueJobs
|
|
63
80
|
|
64
81
|
app.get "/locks/:digest/delete" do
|
65
82
|
digests.delete_by_digest(params[:digest])
|
83
|
+
expiring_digests.delete_by_digest(params[:digest])
|
66
84
|
redirect_to :locks
|
67
85
|
end
|
68
86
|
|
@@ -82,8 +100,9 @@ begin
|
|
82
100
|
require "sidekiq/web" unless defined?(Sidekiq::Web)
|
83
101
|
|
84
102
|
Sidekiq::Web.register(SidekiqUniqueJobs::Web)
|
85
|
-
Sidekiq::Web.tabs["Locks"]
|
86
|
-
Sidekiq::Web.tabs["
|
103
|
+
Sidekiq::Web.tabs["Locks"] = "locks"
|
104
|
+
Sidekiq::Web.tabs["Expiring Locks"] = "expiring_locks"
|
105
|
+
Sidekiq::Web.tabs["Changelogs"] = "changelogs"
|
87
106
|
Sidekiq::Web.settings.locales << File.join(File.dirname(__FILE__), "locales")
|
88
107
|
rescue NameError, LoadError => ex
|
89
108
|
SidekiqUniqueJobs.logger.error(ex)
|
data/lib/sidekiq_unique_jobs.rb
CHANGED
@@ -72,6 +72,7 @@ require "sidekiq_unique_jobs/sidekiq_unique_ext"
|
|
72
72
|
require "sidekiq_unique_jobs/on_conflict"
|
73
73
|
require "sidekiq_unique_jobs/changelog"
|
74
74
|
require "sidekiq_unique_jobs/digests"
|
75
|
+
require "sidekiq_unique_jobs/expiring_digests"
|
75
76
|
|
76
77
|
require "sidekiq_unique_jobs/config"
|
77
78
|
require "sidekiq_unique_jobs/sidekiq_unique_jobs"
|
data/lib/tasks/changelog.rake
CHANGED
@@ -17,7 +17,7 @@ COMMIT_CHANGELOG_CMD = "git commit -a -m 'Update changelog'"
|
|
17
17
|
desc "Generate a Changelog"
|
18
18
|
task :changelog do
|
19
19
|
sh("git checkout main")
|
20
|
-
sh(*CHANGELOG_CMD.push(ENV
|
20
|
+
sh(*CHANGELOG_CMD.push(ENV.fetch("CHANGELOG_GITHUB_TOKEN", nil)))
|
21
21
|
sh(ADD_CHANGELOG_CMD)
|
22
22
|
sh(COMMIT_CHANGELOG_CMD)
|
23
23
|
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: 7.1.
|
4
|
+
version: 7.1.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikael Henriksson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: brpoplpush-redis_script
|
@@ -50,6 +50,20 @@ dependencies:
|
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 1.0.5
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: redis
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "<"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '5.0'
|
60
|
+
type: :runtime
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "<"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '5.0'
|
53
67
|
- !ruby/object:Gem::Dependency
|
54
68
|
name: sidekiq
|
55
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,7 +73,7 @@ dependencies:
|
|
59
73
|
version: '5.0'
|
60
74
|
- - "<"
|
61
75
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
76
|
+
version: '7.0'
|
63
77
|
type: :runtime
|
64
78
|
prerelease: false
|
65
79
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -69,7 +83,7 @@ dependencies:
|
|
69
83
|
version: '5.0'
|
70
84
|
- - "<"
|
71
85
|
- !ruby/object:Gem::Version
|
72
|
-
version: '
|
86
|
+
version: '7.0'
|
73
87
|
- !ruby/object:Gem::Dependency
|
74
88
|
name: thor
|
75
89
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,6 +130,7 @@ files:
|
|
116
130
|
- lib/sidekiq_unique_jobs/deprecation.rb
|
117
131
|
- lib/sidekiq_unique_jobs/digests.rb
|
118
132
|
- lib/sidekiq_unique_jobs/exceptions.rb
|
133
|
+
- lib/sidekiq_unique_jobs/expiring_digests.rb
|
119
134
|
- lib/sidekiq_unique_jobs/job.rb
|
120
135
|
- lib/sidekiq_unique_jobs/json.rb
|
121
136
|
- lib/sidekiq_unique_jobs/key.rb
|
@@ -144,6 +159,7 @@ files:
|
|
144
159
|
- lib/sidekiq_unique_jobs/lua/delete_job_by_digest.lua
|
145
160
|
- lib/sidekiq_unique_jobs/lua/find_digest_in_queues.lua
|
146
161
|
- lib/sidekiq_unique_jobs/lua/lock.lua
|
162
|
+
- lib/sidekiq_unique_jobs/lua/lock_until_expired.lua
|
147
163
|
- lib/sidekiq_unique_jobs/lua/locked.lua
|
148
164
|
- lib/sidekiq_unique_jobs/lua/queue.lua
|
149
165
|
- lib/sidekiq_unique_jobs/lua/reap_orphans.lua
|
@@ -211,15 +227,11 @@ files:
|
|
211
227
|
- lib/sidekiq_unique_jobs/web/views/lock.erb
|
212
228
|
- lib/sidekiq_unique_jobs/web/views/locks.erb
|
213
229
|
- lib/tasks/changelog.rake
|
214
|
-
homepage: https://
|
230
|
+
homepage: https://github.com/mhenrixon/sidekiq-unique-jobs
|
215
231
|
licenses:
|
216
232
|
- MIT
|
217
233
|
metadata:
|
218
|
-
|
219
|
-
bug_tracker_uri: https://github.com/mhenrixon/sidekiq-unique-jobs/issues
|
220
|
-
documentation_uri: https://mhenrixon.github.io/sidekiq-unique-jobs
|
221
|
-
source_code_uri: https://github.com/mhenrixon/sidekiq-unique-jobs
|
222
|
-
changelog_uri: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/master/CHANGELOG.md
|
234
|
+
rubygems_mfa_required: 'true'
|
223
235
|
post_install_message: |
|
224
236
|
IMPORTANT!
|
225
237
|
|
@@ -261,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
261
273
|
- !ruby/object:Gem::Version
|
262
274
|
version: '0'
|
263
275
|
requirements: []
|
264
|
-
rubygems_version: 3.
|
276
|
+
rubygems_version: 3.3.26
|
265
277
|
signing_key:
|
266
278
|
specification_version: 4
|
267
279
|
summary: Sidekiq middleware that prevents duplicates jobs
|