sidekiq-unique-jobs 7.0.13 → 7.1.0
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 +13 -0
- data/README.md +92 -25
- data/lib/sidekiq_unique_jobs/config.rb +16 -8
- data/lib/sidekiq_unique_jobs/constants.rb +44 -45
- data/lib/sidekiq_unique_jobs/deprecation.rb +35 -0
- data/lib/sidekiq_unique_jobs/exceptions.rb +9 -0
- data/lib/sidekiq_unique_jobs/lock/base_lock.rb +56 -51
- data/lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb +31 -9
- data/lib/sidekiq_unique_jobs/lock/until_executed.rb +17 -5
- data/lib/sidekiq_unique_jobs/lock/until_executing.rb +15 -1
- data/lib/sidekiq_unique_jobs/lock/until_expired.rb +21 -0
- data/lib/sidekiq_unique_jobs/lock/while_executing.rb +12 -7
- data/lib/sidekiq_unique_jobs/lock_config.rb +1 -1
- data/lib/sidekiq_unique_jobs/lock_ttl.rb +1 -1
- data/lib/sidekiq_unique_jobs/locksmith.rb +80 -81
- data/lib/sidekiq_unique_jobs/middleware/client.rb +8 -10
- data/lib/sidekiq_unique_jobs/middleware/server.rb +2 -0
- data/lib/sidekiq_unique_jobs/on_conflict/reschedule.rb +7 -3
- data/lib/sidekiq_unique_jobs/options_with_fallback.rb +4 -11
- data/lib/sidekiq_unique_jobs/orphans/manager.rb +1 -0
- data/lib/sidekiq_unique_jobs/orphans/reaper_resurrector.rb +170 -0
- data/lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb +1 -1
- data/lib/sidekiq_unique_jobs/redis/sorted_set.rb +1 -1
- data/lib/sidekiq_unique_jobs/reflectable.rb +17 -0
- data/lib/sidekiq_unique_jobs/reflections.rb +68 -0
- data/lib/sidekiq_unique_jobs/script/caller.rb +3 -1
- data/lib/sidekiq_unique_jobs/server.rb +2 -1
- data/lib/sidekiq_unique_jobs/sidekiq_unique_ext.rb +13 -35
- data/lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb +21 -0
- data/lib/sidekiq_unique_jobs/version.rb +1 -1
- data/lib/sidekiq_unique_jobs.rb +4 -0
- data/lib/tasks/changelog.rake +14 -14
- metadata +12 -8
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SidekiqUniqueJobs
|
4
|
+
#
|
5
|
+
# Module Reflectable provides a method to notify subscribers
|
6
|
+
#
|
7
|
+
# @author Mikael Henriksson <mikael@mhenrixon.com>
|
8
|
+
#
|
9
|
+
module Reflectable
|
10
|
+
def reflect(name, *args)
|
11
|
+
SidekiqUniqueJobs.reflections.dispatch(name, *args)
|
12
|
+
nil
|
13
|
+
rescue UniqueJobsError => ex
|
14
|
+
SidekiqUniqueJobs.logger.error(ex)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SidekiqUniqueJobs
|
4
|
+
#
|
5
|
+
# Class NotificationCollection provides a collection with known notifications
|
6
|
+
#
|
7
|
+
# @author Mikael Henriksson <mikael@mhenrixon.com>
|
8
|
+
#
|
9
|
+
class Reflections
|
10
|
+
#
|
11
|
+
# @return [Array<Symbol>] list of notifications
|
12
|
+
REFLECTIONS = [
|
13
|
+
:after_unlock_callback_failed,
|
14
|
+
:debug,
|
15
|
+
:duplicate,
|
16
|
+
:error,
|
17
|
+
:execution_failed,
|
18
|
+
:lock_failed,
|
19
|
+
:locked,
|
20
|
+
:reschedule_failed,
|
21
|
+
:rescheduled,
|
22
|
+
:timeout,
|
23
|
+
:unknown_sidekiq_worker,
|
24
|
+
:unlock_failed,
|
25
|
+
:unlocked,
|
26
|
+
].freeze
|
27
|
+
|
28
|
+
#
|
29
|
+
# @return [Hash<Symbol, Array<Symbol, String>>] a hash with deprecated notifications
|
30
|
+
DEPRECATIONS = {}.freeze
|
31
|
+
|
32
|
+
REFLECTIONS.each do |reflection|
|
33
|
+
class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
34
|
+
def #{reflection}(*args, &block) # def unlock_failed(*args, &block)
|
35
|
+
raise NoBlockGiven, "block required" unless block_given? # raise NoBlockGiven, "block required" unless block_given?
|
36
|
+
@reflections[:#{reflection}] = block # @notifications[:unlock_failed] = block
|
37
|
+
end # end
|
38
|
+
RUBY
|
39
|
+
end
|
40
|
+
|
41
|
+
def initialize
|
42
|
+
@reflections = {}
|
43
|
+
end
|
44
|
+
|
45
|
+
def dispatch(reflection, *args)
|
46
|
+
if (block = @reflections[reflection])
|
47
|
+
block.call(*args)
|
48
|
+
|
49
|
+
if DEPRECATIONS.key?(reflection)
|
50
|
+
replacement, removal_version = DEPRECATIONS[reflection]
|
51
|
+
SidekiqUniqueJobs::Deprecation.warn(
|
52
|
+
"#{reflection} is deprecated and will be removed in version #{removal_version}. Use #{replacement} instead.",
|
53
|
+
)
|
54
|
+
end
|
55
|
+
elsif misconfigured?(reflection)
|
56
|
+
raise NoSuchNotificationError, reflection
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def configured?(reflection)
|
61
|
+
REFLECTIONS.include?(reflection)
|
62
|
+
end
|
63
|
+
|
64
|
+
def misconfigured?(reflection)
|
65
|
+
!configured?(reflection)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -45,7 +45,9 @@ module SidekiqUniqueJobs
|
|
45
45
|
pool = defined?(redis_pool) ? redis_pool : nil
|
46
46
|
|
47
47
|
redis(pool) do |new_conn|
|
48
|
-
do_call(file_name, new_conn, keys, argv)
|
48
|
+
result = do_call(file_name, new_conn, keys, argv)
|
49
|
+
yield result if block_given?
|
50
|
+
result
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
@@ -5,7 +5,7 @@ module SidekiqUniqueJobs
|
|
5
5
|
#
|
6
6
|
# @author Mikael Henriksson <mikael@mhenrixon.com>
|
7
7
|
class Server
|
8
|
-
DEATH_HANDLER
|
8
|
+
DEATH_HANDLER ||= (lambda do |job, _ex|
|
9
9
|
return unless (digest = job["lock_digest"])
|
10
10
|
|
11
11
|
SidekiqUniqueJobs::Digests.new.delete_by_digest(digest)
|
@@ -29,6 +29,7 @@ module SidekiqUniqueJobs
|
|
29
29
|
SidekiqUniqueJobs::UpdateVersion.call
|
30
30
|
SidekiqUniqueJobs::UpgradeLocks.call
|
31
31
|
SidekiqUniqueJobs::Orphans::Manager.start
|
32
|
+
SidekiqUniqueJobs::Orphans::ReaperResurrector.start
|
32
33
|
end
|
33
34
|
|
34
35
|
def self.stop
|
@@ -68,46 +68,24 @@ module Sidekiq
|
|
68
68
|
prepend UniqueExtension
|
69
69
|
end
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
71
|
+
# See Sidekiq::Api
|
72
|
+
class Job
|
73
|
+
#
|
74
|
+
# Provides extensions for unlocking jobs that are removed and deleted
|
75
|
+
#
|
76
|
+
# @author Mikael Henriksson <mikael@mhenrixon.com>
|
77
|
+
#
|
78
|
+
module UniqueExtension
|
76
79
|
#
|
77
|
-
#
|
80
|
+
# Wraps the original method to ensure locks for the job are deleted
|
78
81
|
#
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
#
|
83
|
-
def delete
|
84
|
-
SidekiqUniqueJobs::Unlockable.delete!(item)
|
85
|
-
super
|
86
|
-
end
|
82
|
+
def delete
|
83
|
+
SidekiqUniqueJobs::Unlockable.delete!(item)
|
84
|
+
super
|
87
85
|
end
|
88
|
-
|
89
|
-
prepend UniqueExtension
|
90
86
|
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
|
108
87
|
|
109
|
-
|
110
|
-
end
|
88
|
+
prepend UniqueExtension
|
111
89
|
end
|
112
90
|
|
113
91
|
# See Sidekiq::Api
|
@@ -270,4 +270,25 @@ module SidekiqUniqueJobs # rubocop:disable Metrics/ModuleLength
|
|
270
270
|
raise
|
271
271
|
end
|
272
272
|
end
|
273
|
+
|
274
|
+
#
|
275
|
+
# Collection with notifications
|
276
|
+
#
|
277
|
+
#
|
278
|
+
# @return [Reflections]
|
279
|
+
#
|
280
|
+
def reflections
|
281
|
+
@reflections ||= Reflections.new
|
282
|
+
end
|
283
|
+
|
284
|
+
#
|
285
|
+
# Yields notification stack for sidekiq unique jobs to configure notifications
|
286
|
+
#
|
287
|
+
#
|
288
|
+
# @return [void] <description>
|
289
|
+
#
|
290
|
+
# @yieldparam [Reflections] x used to configure notifications
|
291
|
+
def reflect
|
292
|
+
yield reflections if block_given?
|
293
|
+
end
|
273
294
|
end
|
data/lib/sidekiq_unique_jobs.rb
CHANGED
@@ -15,6 +15,9 @@ require "json"
|
|
15
15
|
require "pathname"
|
16
16
|
require "sidekiq"
|
17
17
|
|
18
|
+
require "sidekiq_unique_jobs/deprecation"
|
19
|
+
require "sidekiq_unique_jobs/reflections"
|
20
|
+
require "sidekiq_unique_jobs/reflectable"
|
18
21
|
require "sidekiq_unique_jobs/timer_task"
|
19
22
|
require "sidekiq_unique_jobs/version"
|
20
23
|
require "sidekiq_unique_jobs/version_check"
|
@@ -41,6 +44,7 @@ require "sidekiq_unique_jobs/batch_delete"
|
|
41
44
|
require "sidekiq_unique_jobs/orphans/reaper"
|
42
45
|
require "sidekiq_unique_jobs/orphans/observer"
|
43
46
|
require "sidekiq_unique_jobs/orphans/manager"
|
47
|
+
require "sidekiq_unique_jobs/orphans/reaper_resurrector"
|
44
48
|
require "sidekiq_unique_jobs/cli"
|
45
49
|
require "sidekiq_unique_jobs/core_ext"
|
46
50
|
require "sidekiq_unique_jobs/lock_timeout"
|
data/lib/tasks/changelog.rake
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# rubocop:disable Style/MutableConstant
|
4
|
-
CHANGELOG_CMD = %w[
|
5
|
-
github_changelog_generator
|
6
|
-
--no-verbose
|
7
|
-
--user
|
8
|
-
mhenrixon
|
9
|
-
--project
|
10
|
-
sidekiq-unique-jobs
|
11
|
-
--token
|
12
|
-
]
|
13
|
-
ADD_CHANGELOG_CMD = "git add --all"
|
14
|
-
COMMIT_CHANGELOG_CMD = "git commit -a -m 'Update changelog'"
|
15
|
-
# rubocop:enable Style/MutableConstant
|
16
|
-
|
17
3
|
desc "Generate a Changelog"
|
18
4
|
task :changelog do
|
5
|
+
# rubocop:disable Style/MutableConstant
|
6
|
+
CHANGELOG_CMD ||= %w[
|
7
|
+
github_changelog_generator
|
8
|
+
--no-verbose
|
9
|
+
--user
|
10
|
+
mhenrixon
|
11
|
+
--project
|
12
|
+
sidekiq-unique-jobs
|
13
|
+
--token
|
14
|
+
]
|
15
|
+
ADD_CHANGELOG_CMD ||= "git add --all"
|
16
|
+
COMMIT_CHANGELOG_CMD ||= "git commit -a -m 'Update changelog'"
|
17
|
+
# rubocop:enable Style/MutableConstant
|
18
|
+
|
19
19
|
sh("git checkout master")
|
20
20
|
sh(*CHANGELOG_CMD.push(ENV["CHANGELOG_GITHUB_TOKEN"]))
|
21
21
|
sh(ADD_CHANGELOG_CMD)
|
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.0
|
4
|
+
version: 7.1.0
|
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-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: brpoplpush-redis_script
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
version: '5.0'
|
60
60
|
- - "<"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
62
|
+
version: '7.0'
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -69,7 +69,7 @@ dependencies:
|
|
69
69
|
version: '5.0'
|
70
70
|
- - "<"
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version: '
|
72
|
+
version: '7.0'
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
74
|
name: thor
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -79,7 +79,7 @@ dependencies:
|
|
79
79
|
version: '0.20'
|
80
80
|
- - "<"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '2.0'
|
83
83
|
type: :runtime
|
84
84
|
prerelease: false
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -89,7 +89,7 @@ dependencies:
|
|
89
89
|
version: '0.20'
|
90
90
|
- - "<"
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version: '
|
92
|
+
version: '2.0'
|
93
93
|
description: |
|
94
94
|
Prevents simultaneous Sidekiq jobs with the same unique arguments to run.
|
95
95
|
Highly configurable to suite your specific needs.
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- lib/sidekiq_unique_jobs/connection.rb
|
114
114
|
- lib/sidekiq_unique_jobs/constants.rb
|
115
115
|
- lib/sidekiq_unique_jobs/core_ext.rb
|
116
|
+
- lib/sidekiq_unique_jobs/deprecation.rb
|
116
117
|
- lib/sidekiq_unique_jobs/digests.rb
|
117
118
|
- lib/sidekiq_unique_jobs/exceptions.rb
|
118
119
|
- lib/sidekiq_unique_jobs/job.rb
|
@@ -176,6 +177,7 @@ files:
|
|
176
177
|
- lib/sidekiq_unique_jobs/orphans/null_reaper.rb
|
177
178
|
- lib/sidekiq_unique_jobs/orphans/observer.rb
|
178
179
|
- lib/sidekiq_unique_jobs/orphans/reaper.rb
|
180
|
+
- lib/sidekiq_unique_jobs/orphans/reaper_resurrector.rb
|
179
181
|
- lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb
|
180
182
|
- lib/sidekiq_unique_jobs/redis.rb
|
181
183
|
- lib/sidekiq_unique_jobs/redis/entity.rb
|
@@ -184,6 +186,8 @@ files:
|
|
184
186
|
- lib/sidekiq_unique_jobs/redis/set.rb
|
185
187
|
- lib/sidekiq_unique_jobs/redis/sorted_set.rb
|
186
188
|
- lib/sidekiq_unique_jobs/redis/string.rb
|
189
|
+
- lib/sidekiq_unique_jobs/reflectable.rb
|
190
|
+
- lib/sidekiq_unique_jobs/reflections.rb
|
187
191
|
- lib/sidekiq_unique_jobs/rspec/matchers.rb
|
188
192
|
- lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
|
189
193
|
- lib/sidekiq_unique_jobs/script.rb
|
@@ -250,14 +254,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
250
254
|
requirements:
|
251
255
|
- - ">="
|
252
256
|
- !ruby/object:Gem::Version
|
253
|
-
version:
|
257
|
+
version: 2.5.0
|
254
258
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
255
259
|
requirements:
|
256
260
|
- - ">="
|
257
261
|
- !ruby/object:Gem::Version
|
258
262
|
version: '0'
|
259
263
|
requirements: []
|
260
|
-
rubygems_version: 3.2.
|
264
|
+
rubygems_version: 3.2.21
|
261
265
|
signing_key:
|
262
266
|
specification_version: 4
|
263
267
|
summary: Sidekiq middleware that prevents duplicates jobs
|