sidekiq-unique-jobs 7.1.33 → 8.0.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.

Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2 -2
  3. data/lib/sidekiq_unique_jobs/batch_delete.rb +1 -5
  4. data/lib/sidekiq_unique_jobs/changelog.rb +4 -14
  5. data/lib/sidekiq_unique_jobs/connection.rb +4 -7
  6. data/lib/sidekiq_unique_jobs/digests.rb +2 -12
  7. data/lib/sidekiq_unique_jobs/job.rb +0 -5
  8. data/lib/sidekiq_unique_jobs/lock/until_executed.rb +0 -1
  9. data/lib/sidekiq_unique_jobs/lock/while_executing.rb +2 -2
  10. data/lib/sidekiq_unique_jobs/locksmith.rb +4 -15
  11. data/lib/sidekiq_unique_jobs/lua/delete.lua +2 -5
  12. data/lib/sidekiq_unique_jobs/lua/delete_by_digest.lua +2 -5
  13. data/lib/sidekiq_unique_jobs/lua/reap_orphans.lua +2 -5
  14. data/lib/sidekiq_unique_jobs/lua/shared/_delete_from_sorted_set.lua +1 -0
  15. data/lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_process_set.lua +1 -1
  16. data/lib/sidekiq_unique_jobs/lua/unlock.lua +6 -9
  17. data/lib/sidekiq_unique_jobs/lua/upgrade.lua +0 -2
  18. data/lib/sidekiq_unique_jobs/on_conflict/reject.rb +0 -43
  19. data/lib/sidekiq_unique_jobs/options_with_fallback.rb +1 -1
  20. data/lib/sidekiq_unique_jobs/orphans/manager.rb +2 -2
  21. data/lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb +5 -9
  22. data/lib/sidekiq_unique_jobs/redis/sorted_set.rb +9 -2
  23. data/lib/sidekiq_unique_jobs/reflections.rb +1 -1
  24. data/lib/sidekiq_unique_jobs/script/caller.rb +14 -8
  25. data/lib/sidekiq_unique_jobs/server.rb +0 -1
  26. data/lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb +5 -5
  27. data/lib/sidekiq_unique_jobs/upgrade_locks.rb +7 -10
  28. data/lib/sidekiq_unique_jobs/version.rb +1 -1
  29. data/lib/sidekiq_unique_jobs/web/helpers.rb +2 -2
  30. data/lib/sidekiq_unique_jobs/web/views/changelogs.erb +44 -38
  31. data/lib/sidekiq_unique_jobs/web/views/lock.erb +3 -5
  32. data/lib/sidekiq_unique_jobs/web/views/locks.erb +42 -37
  33. data/lib/sidekiq_unique_jobs/web.rb +15 -17
  34. data/lib/sidekiq_unique_jobs.rb +0 -1
  35. metadata +11 -52
  36. data/lib/sidekiq_unique_jobs/lock_type.rb +0 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02bb9ffa139a253d74b8311952767e72cf48499d8071342d433fcd1d185f31c7
4
- data.tar.gz: 2550ac532b5dd0ec61b70bababa532acbf35851ba34f888ba4269c88d95fdce2
3
+ metadata.gz: 2101cca32c043a044df29b2bcd2d8ba58054aa6162d70bdf0f6b54e1237ad3fd
4
+ data.tar.gz: eed69a742091cc23d4362f258105be1175abe25f54058a4a83178f99820bef69
5
5
  SHA512:
6
- metadata.gz: 0c45478c4da0ef2150fab5684e2817bbbdd61ef6a8f87cdc74cf7e80c84779d9bf425c872e783ff5356133cb416c9313736e5a5a3a6782cc5f610bbfcc2769f2
7
- data.tar.gz: d9beeeae13dd13612ac422257f501a9da5c16229b9b67706784ef3479a7c7c8faf329710683548e21070e9b8860e0b66920969a08b129c0600a87354205ca806
6
+ metadata.gz: 60691cad84cc2ed74ff2edf8d6028488dfcff10b5be4c360e91873785e824f1ddef6ea0a56ce3339bc1a96f745990eb52956a85c4e0d2fde1b9893b1de66d145
7
+ data.tar.gz: 5b5ca3b64971118236c984fea50de9cf010b9e848a7a2460d4b5c000e1e288c672775c149109f29d3b1efaef1485ccb0aedb5404da23a8f500b3e82a1af37563
data/CHANGELOG.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Changelog
2
2
 
3
- ## [Unreleased](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/HEAD)
3
+ ## [v7.1.29](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.1.29) (2022-12-03)
4
4
 
5
- [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.1.28...HEAD)
5
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.1.28...v7.1.29)
6
6
 
7
7
  **Fixed bugs:**
8
8
 
@@ -103,11 +103,7 @@ module SidekiqUniqueJobs
103
103
  def del_digest(pipeline, digest)
104
104
  removable_keys = keys_for_digest(digest)
105
105
 
106
- if VersionCheck.satisfied?(redis_version, ">= 4.0.0")
107
- pipeline.unlink(*removable_keys)
108
- else
109
- pipeline.del(*removable_keys)
110
- end
106
+ pipeline.unlink(*removable_keys)
111
107
  end
112
108
 
113
109
  def keys_for_digest(digest)
@@ -7,13 +7,6 @@ module SidekiqUniqueJobs
7
7
  # @author Mikael Henriksson <mikael@mhenrixon.com>
8
8
  #
9
9
  class Changelog < Redis::SortedSet
10
- #
11
- # @return [Integer] the number of matches to return by default
12
- DEFAULT_COUNT = 1_000
13
- #
14
- # @return [String] the default pattern to use for matching
15
- SCAN_PATTERN = "*"
16
-
17
10
  def initialize
18
11
  super(CHANGELOGS)
19
12
  end
@@ -42,12 +35,8 @@ module SidekiqUniqueJobs
42
35
  # @return [Array<Hash>] an array of entries
43
36
  #
44
37
  def entries(pattern: SCAN_PATTERN, count: DEFAULT_COUNT)
45
- options = {}
46
- options[:match] = pattern
47
- options[:count] = count
48
-
49
38
  redis do |conn|
50
- conn.zscan_each(key, **options).to_a.map { |entry| load_json(entry[0]) }
39
+ conn.zscan(key, match: pattern, count: count).to_a.map { |entry| load_json(entry[0]) }
51
40
  end
52
41
  end
53
42
 
@@ -67,10 +56,11 @@ module SidekiqUniqueJobs
67
56
  pipeline.zscan(key, cursor, match: pattern, count: page_size)
68
57
  end
69
58
 
59
+ # NOTE: When debugging, check the last item in the returned array.
70
60
  [
71
61
  total_size.to_i,
72
- result[0].to_i, # next_cursor
73
- result[1].map { |entry| load_json(entry[0]) }, # entries
62
+ result[0].to_i, # next_cursor
63
+ result[1].map { |entry| load_json(entry) }.select { |entry| entry.is_a?(Hash) },
74
64
  ]
75
65
  end
76
66
  end
@@ -10,13 +10,10 @@ module SidekiqUniqueJobs
10
10
  end
11
11
 
12
12
  # Creates a connection to redis
13
- # @return [Sidekiq::RedisConnection, ConnectionPool] a connection to redis
14
- def redis(r_pool = nil, &block)
15
- r_pool ||= defined?(redis_pool) ? redis_pool : r_pool
16
- if r_pool
17
- r_pool.with(&block)
18
- else
19
- Sidekiq.redis(&block)
13
+ # @return [Sidekiq::RedisConnection] a connection to redis
14
+ def redis(_r_pool = nil, &block)
15
+ Sidekiq.redis do |conn|
16
+ conn.with(&block)
20
17
  end
21
18
  end
22
19
  end
@@ -7,13 +7,6 @@ module SidekiqUniqueJobs
7
7
  # @author Mikael Henriksson <mikael@mhenrixon.com>
8
8
  #
9
9
  class Digests < Redis::SortedSet
10
- #
11
- # @return [Integer] the number of matches to return by default
12
- DEFAULT_COUNT = 1_000
13
- #
14
- # @return [String] the default pattern to use for matching
15
- SCAN_PATTERN = "*"
16
-
17
10
  def initialize(digests_key = DIGESTS)
18
11
  super(digests_key)
19
12
  end
@@ -77,11 +70,7 @@ module SidekiqUniqueJobs
77
70
  # @return [Array<String>] an array of digests matching the given pattern
78
71
  #
79
72
  def entries(pattern: SCAN_PATTERN, count: DEFAULT_COUNT)
80
- options = {}
81
- options[:match] = pattern
82
- options[:count] = count
83
-
84
- redis { |conn| conn.zscan_each(key, **options).to_a }.to_h
73
+ redis { |conn| conn.zscan(key, match: pattern, count: count).to_a }.to_h
85
74
  end
86
75
 
87
76
  #
@@ -100,6 +89,7 @@ module SidekiqUniqueJobs
100
89
  pipeline.zscan(key, cursor, match: pattern, count: page_size)
101
90
  end
102
91
 
92
+ # NOTE: When debugging, check the last item in the returned array.
103
93
  [
104
94
  total_size.to_i,
105
95
  digests[0].to_i, # next_cursor
@@ -11,7 +11,6 @@ module SidekiqUniqueJobs
11
11
  # @return [Hash] the job hash
12
12
  def prepare(item)
13
13
  stringify_on_conflict_hash(item)
14
- add_lock_type(item)
15
14
  add_lock_timeout(item)
16
15
  add_lock_ttl(item)
17
16
  add_digest(item)
@@ -55,9 +54,5 @@ module SidekiqUniqueJobs
55
54
  def add_lock_prefix(item)
56
55
  item[LOCK_PREFIX] ||= SidekiqUniqueJobs.config.lock_prefix
57
56
  end
58
-
59
- def add_lock_type(item)
60
- item[LOCK] ||= SidekiqUniqueJobs::LockType.call(item)
61
- end
62
57
  end
63
58
  end
@@ -35,7 +35,6 @@ module SidekiqUniqueJobs
35
35
  def execute
36
36
  executed = locksmith.execute do
37
37
  yield
38
- ensure
39
38
  unlock_and_callback
40
39
  end
41
40
 
@@ -42,9 +42,9 @@ module SidekiqUniqueJobs
42
42
  with_logging_context do
43
43
  executed = locksmith.execute do
44
44
  yield
45
- item[JID]
45
+ callback_safely if locksmith.unlock
46
46
  ensure
47
- unlock_and_callback
47
+ locksmith.unlock
48
48
  end
49
49
 
50
50
  unless executed
@@ -127,10 +127,7 @@ module SidekiqUniqueJobs
127
127
  #
128
128
  def unlock!(conn = nil)
129
129
  call_script(:unlock, key.to_a, argv, conn) do |unlocked_jid|
130
- if unlocked_jid == job_id
131
- reflect(:debug, :unlocked, item, unlocked_jid)
132
- reflect(:unlocked, item)
133
- end
130
+ reflect(:debug, :unlocked, item, unlocked_jid) if unlocked_jid == job_id
134
131
 
135
132
  unlocked_jid
136
133
  end
@@ -243,7 +240,7 @@ module SidekiqUniqueJobs
243
240
  # @return [nil] when lock was not possible
244
241
  # @return [Object] whatever the block returns when lock was acquired
245
242
  #
246
- def primed_async(conn, wait = nil, &block)
243
+ def primed_async(conn, wait = nil, &block) # rubocop:disable Metrics/MethodLength
247
244
  timeout = (wait || config.timeout).to_i
248
245
  timeout = 1 if timeout.zero?
249
246
 
@@ -308,15 +305,7 @@ module SidekiqUniqueJobs
308
305
  # passing timeout 0 to brpoplpush causes it to block indefinitely
309
306
  raise InvalidArgument, "wait must be an integer" unless wait.is_a?(Integer)
310
307
 
311
- if defined?(::Redis::Namespace) && conn.instance_of?(::Redis::Namespace)
312
- return conn.brpoplpush(key.queued, key.primed, wait)
313
- end
314
-
315
- if VersionCheck.satisfied?(redis_version, ">= 6.2.0") && conn.respond_to?(:blmove)
316
- conn.blmove(key.queued, key.primed, "RIGHT", "LEFT", timeout: wait)
317
- else
318
- conn.brpoplpush(key.queued, key.primed, timeout: wait)
319
- end
308
+ conn.blmove(key.queued, key.primed, "RIGHT", "LEFT", wait)
320
309
  end
321
310
 
322
311
  #
@@ -366,7 +355,7 @@ module SidekiqUniqueJobs
366
355
  # @return [true, false]
367
356
  #
368
357
  def taken?(conn)
369
- conn.hexists(key.locked, job_id)
358
+ conn.hexists(key.locked, job_id) != 0
370
359
  end
371
360
 
372
361
  def argv
@@ -33,15 +33,12 @@ log_debug("BEGIN delete", digest)
33
33
 
34
34
  local redis_version = toversion(redisversion)
35
35
  local count = 0
36
- local del_cmd = "DEL"
37
36
 
38
37
  log_debug("ZREM", digests, digest)
39
38
  count = count + redis.call("ZREM", digests, digest)
40
39
 
41
- if redis_version["major"] >= 4 then del_cmd = "UNLINK"; end
42
-
43
- log_debug(del_cmd, digest, queued, primed, locked, info)
44
- count = count + redis.call(del_cmd, digest, queued, primed, locked, info)
40
+ log_debug("UNLINK", digest, queued, primed, locked, info)
41
+ count = count + redis.call("UNLINK", digest, queued, primed, locked, info)
45
42
 
46
43
 
47
44
  log("Deleted (" .. count .. ") keys")
@@ -25,14 +25,11 @@ local redisversion = tostring(ARGV[5])
25
25
  -------- BEGIN delete_by_digest.lua --------
26
26
  local counter = 0
27
27
  local redis_version = toversion(redisversion)
28
- local del_cmd = "DEL"
29
28
 
30
29
  log_debug("BEGIN delete_by_digest:", digest)
31
30
 
32
- if redis_version["major"] >= 4 then del_cmd = "UNLINK"; end
33
-
34
- log_debug(del_cmd, digest, queued, primed, locked, run_digest, run_queued, run_primed, run_locked)
35
- counter = redis.call(del_cmd, digest, queued, primed, locked, run_digest, run_queued, run_primed, run_locked)
31
+ log_debug("UNLINK", digest, queued, primed, locked, run_digest, run_queued, run_primed, run_locked)
32
+ counter = redis.call("UNLINK", digest, queued, primed, locked, run_digest, run_queued, run_primed, run_locked)
36
33
 
37
34
  log_debug("ZREM", digests, digest)
38
35
  redis.call("ZREM", digests, digest)
@@ -37,9 +37,6 @@ local total = redis.call("ZCARD", digests_set)
37
37
  local index = 0
38
38
  local del_count = 0
39
39
  local redis_ver = toversion(redisversion)
40
- local del_cmd = "DEL"
41
-
42
- if tonumber(redis_ver["major"]) >= 4 then del_cmd = "UNLINK"; end
43
40
 
44
41
  repeat
45
42
  log_debug("Interating through:", digests_set, "for orphaned locks")
@@ -81,7 +78,7 @@ repeat
81
78
  local run_locked = digest .. ":RUN:LOCKED"
82
79
  local run_info = digest .. ":RUN:INFO"
83
80
 
84
- redis.call(del_cmd, digest, queued, primed, locked, info, run_digest, run_queued, run_primed, run_locked, run_info)
81
+ redis.call("UNLINK", digest, queued, primed, locked, info, run_digest, run_queued, run_primed, run_locked, run_info)
85
82
 
86
83
  redis.call("ZREM", digests_set, digest)
87
84
  del_count = del_count + 1
@@ -108,7 +105,7 @@ if del_count < reaper_count then
108
105
  local run_locked = digest .. ":RUN:LOCKED"
109
106
  local run_info = digest .. ":RUN:INFO"
110
107
 
111
- redis.call(del_cmd, digest, queued, primed, locked, info, run_digest, run_queued, run_primed, run_locked, run_info)
108
+ redis.call("UNLINK", digest, queued, primed, locked, info, run_digest, run_queued, run_primed, run_locked, run_info)
112
109
 
113
110
  redis.call("ZREM", expiring_digests_set, digest)
114
111
  del_count = del_count + 1
@@ -3,6 +3,7 @@ local function delete_from_sorted_set(name, digest)
3
3
  local total = redis.call("zcard", name)
4
4
  local index = 0
5
5
  local result
6
+
6
7
  while (index < total) do
7
8
  local items = redis.call("ZRANGE", name, index, index + per -1)
8
9
  for _, item in pairs(items) do
@@ -15,7 +15,7 @@ local function find_digest_in_process_set(digest, threshold)
15
15
  log_debug("Found number of processes:", #processes, "next cursor:", next_process_cursor)
16
16
 
17
17
  for _, process in ipairs(processes) do
18
- local workers_key = process .. ":work"
18
+ local workers_key = process .. ":workers"
19
19
  log_debug("searching in process set:", process,
20
20
  "for digest:", digest,
21
21
  "cursor:", process_cursor)
@@ -66,13 +66,10 @@ log_debug("LREM", primed, -1, job_id)
66
66
  redis.call("LREM", primed, -1, job_id)
67
67
 
68
68
  local redis_version = toversion(redisversion)
69
- local del_cmd = "DEL"
70
-
71
- if tonumber(redis_version["major"]) >= 4 then del_cmd = "UNLINK"; end
72
69
 
73
70
  if lock_type ~= "until_expired" then
74
- log_debug(del_cmd, digest, info)
75
- redis.call(del_cmd, digest, info)
71
+ log_debug("UNLINK", digest, info)
72
+ redis.call("UNLINK", digest, info)
76
73
 
77
74
  log_debug("HDEL", locked, job_id)
78
75
  redis.call("HDEL", locked, job_id)
@@ -81,13 +78,13 @@ end
81
78
  local locked_count = redis.call("HLEN", locked)
82
79
 
83
80
  if locked_count and locked_count < 1 then
84
- log_debug(del_cmd, locked)
85
- redis.call(del_cmd, locked)
81
+ log_debug("UNLINK", locked)
82
+ redis.call("UNLINK", locked)
86
83
  end
87
84
 
88
85
  if redis.call("LLEN", primed) == 0 then
89
- log_debug(del_cmd, primed)
90
- redis.call(del_cmd, primed)
86
+ log_debug("UNLINK", primed)
87
+ redis.call("UNLINK", primed)
91
88
  end
92
89
 
93
90
  if limit and limit <= 1 and locked_count and locked_count <= 1 then
@@ -22,9 +22,7 @@ local new_version = redis.call("GET", live_version)
22
22
  local old_version = redis.call("GET", dead_version)
23
23
  local redis_version = toversion(redisversion)
24
24
  local upgraded = 0
25
- local del_cmd = "DEL"
26
25
 
27
- if redis_version["major"] >= 4 then del_cmd = "UNLINK"; end
28
26
  -------- BEGIN delete.lua --------
29
27
 
30
28
  log_debug("BEGIN upgrading from: ", old_version, "to:", new_version)
@@ -12,33 +12,6 @@ module SidekiqUniqueJobs
12
12
  def call
13
13
  log_info { "Adding dead #{item[CLASS]} job #{item[JID]}" }
14
14
 
15
- if deadset_kill?
16
- deadset_kill
17
- else
18
- push_to_deadset
19
- end
20
- end
21
-
22
- #
23
- # Sidekiq version compatibility check
24
- # @api private
25
- #
26
- #
27
- # @return [true, false] depending on if Sidekiq::Deadset responds to kill
28
- #
29
- def deadset_kill?
30
- deadset.respond_to?(:kill)
31
- end
32
-
33
- #
34
- # Use Sidekiqs built in Sidekiq::DeadSet#kill
35
- # to get rid of the job
36
- # @api private
37
- #
38
- #
39
- # @return [void]
40
- #
41
- def deadset_kill
42
15
  if kill_with_options?
43
16
  kill_job_with_options
44
17
  else
@@ -88,22 +61,6 @@ module SidekiqUniqueJobs
88
61
  @deadset ||= Sidekiq::DeadSet.new
89
62
  end
90
63
 
91
- #
92
- # Used for compatibility with older Sidekiq versions
93
- #
94
- #
95
- # @return [void]
96
- #
97
- def push_to_deadset
98
- redis do |conn|
99
- conn.multi do |pipeline|
100
- pipeline.zadd("dead", now_f, payload)
101
- pipeline.zremrangebyscore("dead", "-inf", now_f - Sidekiq::DeadSet.timeout)
102
- pipeline.zremrangebyrank("dead", 0, -Sidekiq::DeadSet.max_jobs)
103
- end
104
- end
105
- end
106
-
107
64
  #
108
65
  # The Sidekiq job hash as JSON
109
66
  #
@@ -55,7 +55,7 @@ module SidekiqUniqueJobs
55
55
  # The type of lock for this worker
56
56
  #
57
57
  #
58
- # @return [Symbol, NilClass]
58
+ # @return [Symbol]
59
59
  #
60
60
  def lock_type
61
61
  @lock_type ||= options[LOCK] || item[LOCK]
@@ -72,7 +72,7 @@ module SidekiqUniqueJobs
72
72
  # @return [<type>] <description>
73
73
  #
74
74
  def task
75
- @task ||= default_task # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
75
+ @task ||= default_task
76
76
  end
77
77
 
78
78
  #
@@ -100,7 +100,7 @@ module SidekiqUniqueJobs
100
100
  # @return [void]
101
101
  #
102
102
  def task=(task)
103
- @task = task # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
103
+ @task = task
104
104
  end
105
105
 
106
106
  #
@@ -79,11 +79,7 @@ module SidekiqUniqueJobs
79
79
  def expired_digests
80
80
  max_score = (start_time - reaper_timeout).to_f
81
81
 
82
- if VersionCheck.satisfied?(redis_version, ">= 6.2.0") && VersionCheck.satisfied?(::Redis::VERSION, ">= 4.6.0")
83
- conn.zrange(EXPIRING_DIGESTS, 0, max_score, byscore: true)
84
- else
85
- conn.zrangebyscore(EXPIRING_DIGESTS, 0, max_score)
86
- end
82
+ conn.zrange(EXPIRING_DIGESTS, 0, max_score, byscore: true)
87
83
  end
88
84
 
89
85
  #
@@ -184,7 +180,7 @@ module SidekiqUniqueJobs
184
180
 
185
181
  def active?(digest) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
186
182
  Sidekiq.redis do |conn|
187
- procs = conn.sscan_each("processes").to_a
183
+ procs = conn.sscan("processes").to_a
188
184
  return false if procs.empty?
189
185
 
190
186
  procs.sort.each do |key|
@@ -195,7 +191,7 @@ module SidekiqUniqueJobs
195
191
  else
196
192
  pipeline.exists(key)
197
193
  end
198
- pipeline.hgetall("#{key}:work")
194
+ pipeline.hgetall("#{key}:workers")
199
195
  end
200
196
 
201
197
  next unless valid
@@ -235,7 +231,7 @@ module SidekiqUniqueJobs
235
231
  # @yield queues one at a time
236
232
  #
237
233
  def queues(conn, &block)
238
- conn.sscan_each("queues", &block)
234
+ conn.sscan("queues").each(&block)
239
235
  end
240
236
 
241
237
  def entries(conn, queue, &block) # rubocop:disable Metrics/MethodLength
@@ -290,7 +286,7 @@ module SidekiqUniqueJobs
290
286
  # @return [false] when missing
291
287
  #
292
288
  def in_sorted_set?(key, digest)
293
- conn.zscan_each(key, match: "*#{digest}*", count: 1).to_a.any?
289
+ conn.zscan(key, match: "*#{digest}*", count: 1).to_a.any?
294
290
  end
295
291
  end
296
292
  # rubocop:enable Metrics/ClassLength
@@ -8,6 +8,13 @@ module SidekiqUniqueJobs
8
8
  # @author Mikael Henriksson <mikael@mhenrixon.com>
9
9
  #
10
10
  class SortedSet < Entity
11
+ #
12
+ # @return [Integer] the number of matches to return by default
13
+ DEFAULT_COUNT = 1_000
14
+ #
15
+ # @return [String] the default pattern to use for matching
16
+ SCAN_PATTERN = "*"
17
+
11
18
  #
12
19
  # Return entries for this sorted set
13
20
  #
@@ -17,7 +24,7 @@ module SidekiqUniqueJobs
17
24
  # @return [Hash] when given with_scores: true
18
25
  #
19
26
  def entries(with_scores: true)
20
- entrys = redis { |conn| conn.zrange(key, 0, -1, with_scores: with_scores) }
27
+ entrys = redis { |conn| conn.zrange(key, 0, -1, withscores: with_scores) }
21
28
  return entrys unless with_scores
22
29
 
23
30
  entrys.each_with_object({}) { |pair, hash| hash[pair[0]] = pair[1] }
@@ -33,7 +40,7 @@ module SidekiqUniqueJobs
33
40
  def add(values)
34
41
  redis do |conn|
35
42
  if values.is_a?(Array)
36
- conn.zadd(key, values)
43
+ conn.zadd(key, *values)
37
44
  else
38
45
  conn.zadd(key, now_f, values)
39
46
  end
@@ -50,7 +50,7 @@ module SidekiqUniqueJobs
50
50
  #
51
51
  # @return [void] <description>
52
52
  #
53
- def dispatch(reflection, *args)
53
+ def dispatch(reflection, *args) # rubocop:disable Metrics/MethodLength
54
54
  if (block = @reflections[reflection])
55
55
  block.call(*args)
56
56
 
@@ -54,14 +54,9 @@ module SidekiqUniqueJobs
54
54
  # Only used to reduce a little bit of duplication
55
55
  # @see call_script
56
56
  def do_call(file_name, conn, keys, argv)
57
- argv = argv.dup.push(
58
- now_f,
59
- debug_lua,
60
- max_history,
61
- file_name,
62
- redis_version,
63
- )
64
- Script.execute(file_name, conn, keys: keys, argv: argv)
57
+ argv = argv.dup.push(now_f, debug_lua, max_history, file_name, redis_version)
58
+
59
+ Script.execute(file_name, conn, keys: keys, argv: normalize_argv(argv))
65
60
  end
66
61
 
67
62
  #
@@ -122,6 +117,17 @@ module SidekiqUniqueJobs
122
117
  def redis_version
123
118
  SidekiqUniqueJobs.config.redis_version
124
119
  end
120
+
121
+ def normalize_argv(argv)
122
+ argv.each_with_index do |item, index|
123
+ case item
124
+ when FalseClass, NilClass
125
+ argv[index] = 0
126
+ when TrueClass
127
+ argv[index] = 1
128
+ end
129
+ end
130
+ end
125
131
  end
126
132
  end
127
133
  end
@@ -33,7 +33,6 @@ module SidekiqUniqueJobs
33
33
  #
34
34
  def self.start
35
35
  SidekiqUniqueJobs::UpdateVersion.call
36
- SidekiqUniqueJobs::UpgradeLocks.call
37
36
  SidekiqUniqueJobs::Orphans::Manager.start
38
37
  SidekiqUniqueJobs::Orphans::ReaperResurrector.start
39
38
  end
@@ -17,7 +17,7 @@ module SidekiqUniqueJobs # rubocop:disable Metrics/ModuleLength
17
17
  # @return [SidekiqUniqueJobs::Config] the gem configuration
18
18
  #
19
19
  def config
20
- @config ||= reset! # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
20
+ @config ||= reset!
21
21
  end
22
22
 
23
23
  #
@@ -108,7 +108,7 @@ module SidekiqUniqueJobs # rubocop:disable Metrics/ModuleLength
108
108
  # @return [SidekiqUniqueJobs::Config] a default gem configuration
109
109
  #
110
110
  def reset!
111
- @config = SidekiqUniqueJobs::Config.default # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
111
+ @config = SidekiqUniqueJobs::Config.default
112
112
  end
113
113
 
114
114
  #
@@ -186,7 +186,7 @@ module SidekiqUniqueJobs # rubocop:disable Metrics/ModuleLength
186
186
  yield config
187
187
  else
188
188
  options.each do |key, val|
189
- config.send(:"#{key}=", val)
189
+ config.send("#{key}=", val)
190
190
  end
191
191
  end
192
192
  end
@@ -198,7 +198,7 @@ module SidekiqUniqueJobs # rubocop:disable Metrics/ModuleLength
198
198
  # @return [String] a string like `5.0.2`
199
199
  #
200
200
  def fetch_redis_version
201
- Sidekiq.redis_info["redis_version"]
201
+ Sidekiq.default_configuration.redis_info["redis_version"]
202
202
  end
203
203
 
204
204
  #
@@ -288,7 +288,7 @@ module SidekiqUniqueJobs # rubocop:disable Metrics/ModuleLength
288
288
  # @return [Reflections]
289
289
  #
290
290
  def reflections
291
- @reflections ||= Reflections.new # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
291
+ @reflections ||= Reflections.new
292
292
  end
293
293
 
294
294
  #
@@ -6,7 +6,7 @@ module SidekiqUniqueJobs
6
6
  #
7
7
  # @author Mikael Henriksson <mikael@mhenrixon.com>
8
8
  #
9
- class UpgradeLocks # rubocop:disable Metrics/ClassLength
9
+ class UpgradeLocks
10
10
  #
11
11
  # @return [Integer] the number of keys to batch upgrade
12
12
  BATCH_SIZE = 100
@@ -56,9 +56,9 @@ module SidekiqUniqueJobs
56
56
 
57
57
  log_info("Start - Upgrading Locks")
58
58
 
59
- upgrade_v6_locks
60
- delete_unused_v6_keys
61
- delete_supporting_v6_keys
59
+ # upgrade_v6_locks
60
+ # delete_unused_v6_keys
61
+ # delete_supporting_v6_keys
62
62
 
63
63
  conn.hset(upgraded_key, version, now_f)
64
64
  log_info("Done - Upgrading Locks")
@@ -75,10 +75,11 @@ module SidekiqUniqueJobs
75
75
 
76
76
  def upgrade_v6_locks
77
77
  log_info("Start - Converting v6 locks to v7")
78
- conn.scan_each(match: "*:GRABBED", count: BATCH_SIZE) do |grabbed_key|
78
+ conn.scan(match: "*:GRABBED", count: BATCH_SIZE).each do |grabbed_key|
79
79
  upgrade_v6_lock(grabbed_key)
80
80
  @count += 1
81
81
  end
82
+
82
83
  log_info("Done - Converting v6 locks to v7")
83
84
  end
84
85
 
@@ -115,11 +116,7 @@ module SidekiqUniqueJobs
115
116
  return if keys.empty?
116
117
 
117
118
  conn.pipelined do |pipeline|
118
- if VersionCheck.satisfied?(redis_version, ">= 4.0.0")
119
- pipeline.unlink(*keys)
120
- else
121
- pipeline.del(*keys)
122
- end
119
+ pipeline.unlink(*keys)
123
120
  end
124
121
  end
125
122
 
@@ -3,5 +3,5 @@
3
3
  module SidekiqUniqueJobs
4
4
  #
5
5
  # @return [String] the current SidekiqUniqueJobs version
6
- VERSION = "7.1.33"
6
+ VERSION = "8.0.0"
7
7
  end
@@ -80,11 +80,11 @@ module SidekiqUniqueJobs
80
80
  #
81
81
  def cparams(options)
82
82
  stringified_options = options.transform_keys(&:to_s)
83
- params.merge(stringified_options).map do |key, value|
83
+ params.merge(stringified_options).filter_map do |key, value|
84
84
  next unless SAFE_CPARAMS.include?(key)
85
85
 
86
86
  "#{key}=#{CGI.escape(value.to_s)}"
87
- end.compact.join("&")
87
+ end.join("&")
88
88
  end
89
89
 
90
90
  #
@@ -1,54 +1,60 @@
1
1
  <header class="row">
2
2
  <div class="col-sm-5">
3
3
  <h3>
4
- <%= t('Changelog Entries') %>
4
+ <%= t('Changelog Entries') %>
5
5
  </h3>
6
6
  </div>
7
7
  <form action="<%= root_path %>changelogs" class="form form-inline" method="get">
8
8
  <%= csrf_tag %>
9
+
9
10
  <input name="filter" class="form-control" type="text" value="<%= @filter %>" />
11
+
10
12
  <button class="btn btn-default" type="submit">
11
- <%= t('Filter') %>
13
+ <%= t('Filter') %>
12
14
  </button>
13
15
  </form>
16
+
14
17
  <% if @changelogs.any? && @total_size > @count.to_i %>
15
- <div class="col-sm-4">
16
- <%= erb unique_template(:_paging), locals: { url: "#{root_path}changelogs" } %>
17
- </div>
18
+ <div class="col-sm-4">
19
+ <%= erb unique_template(:_paging), locals: { url: "#{root_path}changelogs" } %>
20
+ </div>
18
21
  <% end %>
19
22
  </header>
23
+
20
24
  <% if @changelogs.any? %>
21
- <div class="table_container">
22
- <form action="<%= root_path %>changelogs/delete_all" method="get">
23
- <input class="btn btn-danger btn-xs" type="submit" name="delete_all" value="<%= t('DeleteAll') %>" data-confirm="<%= t('AreYouSure') %>" />
24
- </form>
25
- <br/>
26
- <table class="table table-striped table-bordered table-hover">
27
- <thead>
28
- <tr>
29
- <th><%= t('Time') %></th>
30
- <th><%= t('Digest') %></th>
31
- <th><%= t('Script') %></th>
32
- <th><%= t('JID') %></th>
33
- <th><%= t('Prev JID') %></th>
34
- <th><%= t('Message') %></th>
35
- </tr>
36
- </thead>
37
- <tbody>
38
- <% @changelogs.each do |changelog| %>
39
- <tr class="changelog-row">
40
- <td><%= safe_relative_time(changelog["time"]) %></td>
41
- <td><%= changelog["digest"] %></td>
42
- <td><%= changelog["script"] %></td>
43
- <td><%= changelog["job_id"] %></td>
44
- <td><%= changelog["prev_jid"] %></td>
45
- <td><%= changelog["message"] %></th>
46
- </tr>
47
- <% end %>
48
- </tbody>
49
- </table>
50
- <form action="<%= root_path %>changelogs/delete_all" method="get">
51
- <input class="btn btn-danger btn-xs" type="submit" name="delete_all" value="<%= t('DeleteAll') %>" data-confirm="<%= t('AreYouSure') %>" />
52
- </form>
53
- </div>
25
+ <div class="table_container">
26
+ <form action="<%= root_path %>changelogs/delete_all" method="get">
27
+ <input class="btn btn-danger btn-xs" type="submit" name="delete_all" value="<%= t('DeleteAll') %>" data-confirm="<%= t('AreYouSure') %>" />
28
+ </form>
29
+ <br/>
30
+
31
+ <table class="table table-striped table-bordered table-hover">
32
+ <thead>
33
+ <tr>
34
+ <th><%= t('Time') %></th>
35
+ <th><%= t('Digest') %></th>
36
+ <th><%= t('Script') %></th>
37
+ <th><%= t('JID') %></th>
38
+ <th><%= t('Prev JID') %></th>
39
+ <th><%= t('Message') %></th>
40
+ </tr>
41
+ </thead>
42
+ <tbody>
43
+ <% @changelogs.each do |changelog| %>
44
+ <tr class="changelog-row">
45
+ <td><%= "bogus" %></td>
46
+ <td><%= changelog["digest"] %></td>
47
+ <td><%= changelog["script"] %></td>
48
+ <td><%= changelog["job_id"] %></td>
49
+ <td><%= changelog["prev_jid"] %></td>
50
+ <td><%= changelog["message"] %></th>
51
+ </tr>
52
+ <% end %>
53
+ </tbody>
54
+ </table>
55
+
56
+ <form action="<%= root_path %>changelogs/delete_all" method="get">
57
+ <input class="btn btn-danger btn-xs" type="submit" name="delete_all" value="<%= t('DeleteAll') %>" data-confirm="<%= t('AreYouSure') %>" />
58
+ </form>
59
+ </div>
54
60
  <% end %>
@@ -7,11 +7,9 @@
7
7
  <div class="col-sm-7 table-responsive">
8
8
  <% if @lock.info.none? %>
9
9
  <h3>No Lock Information Available</h3>
10
- <% unless SidekiqUniqueJobs.config.lock_info %>
11
- <p>To use it turn the following setting on:
12
- <code>SidekiqUniqueJobs.config.lock_info = true</code>
13
- </p>
14
- <% end %>
10
+ <p>To use it turn the following setting on:
11
+ <code>SidekiqUniqueJobs.config.lock_info = true</code>
12
+ </p>
15
13
  <% else %>
16
14
  <table class="table table-striped table-bordered table-white table-hover">
17
15
  <caption>Information about lock</caption>
@@ -7,48 +7,53 @@
7
7
  <form action="<%= root_path %>locks" class="form form-inline" method="get">
8
8
  <%= csrf_tag %>
9
9
  <input name="filter" class="form-control" type="text" value="<%= @filter %>" />
10
+
10
11
  <button class="btn btn-default" type="submit">
11
- <%= t('Filter') %>
12
+ <%= t('Filter') %>
12
13
  </button>
14
+
13
15
  </form>
16
+
14
17
  <% if @locks.any? && @total_size > @count %>
15
- <div class="col-sm-4">
16
- <%= erb unique_template(:_paging), locals: { url: "#{root_path}locks" } %>
17
- </div>
18
+ <div class="col-sm-4">
19
+ <%= erb unique_template(:_paging), locals: { url: "#{root_path}locks" } %>
20
+ </div>
18
21
  <% end %>
19
22
  </header>
23
+
20
24
  <% if @locks.any? %>
21
- <div class="table_container">
22
- <table class="table table-striped table-bordered table-hover">
23
- <thead>
24
- <tr>
25
- <th><%= t('Delete') %></th>
26
- <th><%= t('Digest') %></th>
27
- <th><%= t('Lock') %></th>
28
- <th><%= t('Locks') %></th>
29
- <th><%= t('Since') %></th>
30
- </tr>
31
- </thead>
32
- <% @locks.each do |lock| %>
33
- <tbody>
34
- <tr class="lock-row">
35
- <td>
36
- <form action="<%= root_path %>locks/<%= lock.key %>/delete" method="get">
37
- <%= csrf_tag %>
38
- <input name="lock" value="<%= h lock.key %>" type="hidden" />
39
- <input class="btn btn-danger btn-xs" type="submit" name="delete" value="<%= t('Delete') %>" data-confirm="<%= t('AreYouSure') %>" />
40
- </form>
41
- </td>
42
- <td><a href="<%= root_path %>locks/<%= lock.key %>"><%= lock.key %></a></td>
43
- <td><%= lock.info["lock"] %></td>
44
- <td><%= lock.locked.count %></td>
45
- <td><%= safe_relative_time(lock.created_at) %></td>
46
- </tr>
47
- </tbody>
48
- <% end %>
49
- </table>
50
- <form action="<%= root_path %>locks/delete_all" method="get">
51
- <input class="btn btn-danger btn-xs" type="submit" name="delete_all" value="<%= t('DeleteAll') %>" data-confirm="<%= t('AreYouSure') %>" />
52
- </form>
53
- </div>
25
+ <div class="table_container">
26
+ <table class="table table-striped table-bordered table-hover">
27
+ <thead>
28
+ <tr>
29
+ <th><%= t('Delete') %></th>
30
+ <th><%= t('Digest') %></th>
31
+ <th><%= t('Lock') %></th>
32
+ <th><%= t('Locks') %></th>
33
+ <th><%= t('Since') %></th>
34
+ </tr>
35
+ </thead>
36
+ <% @locks.each do |lock| %>
37
+ <tbody>
38
+ <tr class="lock-row">
39
+ <td>
40
+ <form action="<%= root_path %>locks/<%= lock.key %>/delete" method="get">
41
+ <%= csrf_tag %>
42
+ <input name="lock" value="<%= h lock.key %>" type="hidden" />
43
+ <input class="btn btn-danger btn-xs" type="submit" name="delete" value="<%= t('Delete') %>" data-confirm="<%= t('AreYouSure') %>" />
44
+ </form>
45
+ </td>
46
+ <td><a href="<%= root_path %>locks/<%= lock.key %>"><%= lock.key %></a></td>
47
+ <td><%= lock.info["lock"] %></td>
48
+ <td><%= lock.locked.count %></td>
49
+ <td><%= safe_relative_time(lock.created_at) %></td>
50
+ </tr>
51
+ </tbody>
52
+ <% end %>
53
+ </table>
54
+
55
+ <form action="<%= root_path %>locks/delete_all" method="get">
56
+ <input class="btn btn-danger btn-xs" type="submit" name="delete_all" value="<%= t('DeleteAll') %>" data-confirm="<%= t('AreYouSure') %>" />
57
+ </form>
58
+ </div>
54
59
  <% end %>
@@ -5,7 +5,6 @@ require_relative "web/helpers"
5
5
  module SidekiqUniqueJobs
6
6
  # Utility module to help manage unique keys in redis.
7
7
  # Useful for deleting keys that for whatever reason wasn't deleted
8
- #
9
8
  # @author Mikael Henriksson <mikael@mhenrixon.com>
10
9
  module Web
11
10
  def self.registered(app) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
@@ -14,11 +13,11 @@ module SidekiqUniqueJobs
14
13
  end
15
14
 
16
15
  app.get "/changelogs" do
17
- @filter = h(params[:filter] || "*")
16
+ @filter = params[:filter] || "*"
18
17
  @filter = "*" if @filter == ""
19
- @count = h(params[:count] || 100).to_i
20
- @current_cursor = h(params[:cursor])
21
- @prev_cursor = h(params[:prev_cursor])
18
+ @count = (params[:count] || 100).to_i
19
+ @current_cursor = params[:cursor].to_i
20
+ @prev_cursor = params[:prev_cursor].to_i
22
21
  @total_size, @next_cursor, @changelogs = changelog.page(
23
22
  cursor: @current_cursor,
24
23
  pattern: @filter,
@@ -34,11 +33,11 @@ module SidekiqUniqueJobs
34
33
  end
35
34
 
36
35
  app.get "/locks" do
37
- @filter = h(params[:filter] || "*")
36
+ @filter = params[:filter] || "*"
38
37
  @filter = "*" if @filter == ""
39
- @count = h(params[:count] || 100).to_i
40
- @current_cursor = h(params[:cursor])
41
- @prev_cursor = h(params[:prev_cursor])
38
+ @count = (params[:count] || 100).to_i
39
+ @current_cursor = params[:cursor].to_i
40
+ @prev_cursor = params[:prev_cursor].to_i
42
41
 
43
42
  @total_size, @next_cursor, @locks = digests.page(
44
43
  cursor: @current_cursor,
@@ -50,11 +49,11 @@ module SidekiqUniqueJobs
50
49
  end
51
50
 
52
51
  app.get "/expiring_locks" do
53
- @filter = h(params[:filter] || "*")
52
+ @filter = params[:filter] || "*"
54
53
  @filter = "*" if @filter == ""
55
- @count = h(params[:count] || 100).to_i
56
- @current_cursor = h(params[:cursor])
57
- @prev_cursor = h(params[:prev_cursor])
54
+ @count = (params[:count] || 100).to_i
55
+ @current_cursor = params[:cursor].to_i
56
+ @prev_cursor = params[:prev_cursor].to_i
58
57
 
59
58
  @total_size, @next_cursor, @locks = expiring_digests.page(
60
59
  cursor: @current_cursor,
@@ -72,7 +71,7 @@ module SidekiqUniqueJobs
72
71
  end
73
72
 
74
73
  app.get "/locks/:digest" do
75
- @digest = h(params[:digest])
74
+ @digest = params[:digest]
76
75
  @lock = SidekiqUniqueJobs::Lock.new(@digest)
77
76
 
78
77
  erb(unique_template(:lock))
@@ -85,10 +84,9 @@ module SidekiqUniqueJobs
85
84
  end
86
85
 
87
86
  app.get "/locks/:digest/jobs/:job_id/delete" do
88
- @digest = h(params[:digest])
89
- @job_id = h(params[:job_id])
87
+ @digest = params[:digest]
90
88
  @lock = SidekiqUniqueJobs::Lock.new(@digest)
91
- @lock.unlock(@job_id)
89
+ @lock.unlock(params[:job_id])
92
90
 
93
91
  redirect_to "locks/#{@lock.key}"
94
92
  end
@@ -27,7 +27,6 @@ require "sidekiq_unique_jobs/logging"
27
27
  require "sidekiq_unique_jobs/logging/middleware_context"
28
28
  require "sidekiq_unique_jobs/timing"
29
29
  require "sidekiq_unique_jobs/sidekiq_worker_methods"
30
- require "sidekiq_unique_jobs/lock_type"
31
30
  require "sidekiq_unique_jobs/connection"
32
31
  require "sidekiq_unique_jobs/exceptions"
33
32
  require "sidekiq_unique_jobs/script"
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.33
4
+ version: 8.0.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: 2024-02-12 00:00:00.000000000 Z
11
+ date: 2023-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: brpoplpush-redis_script
@@ -50,47 +50,33 @@ 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'
67
53
  - !ruby/object:Gem::Dependency
68
54
  name: sidekiq
69
55
  requirement: !ruby/object:Gem::Requirement
70
56
  requirements:
71
57
  - - ">="
72
58
  - !ruby/object:Gem::Version
73
- version: '5.0'
59
+ version: 7.0.0
74
60
  - - "<"
75
61
  - !ruby/object:Gem::Version
76
- version: '7.0'
62
+ version: 8.0.0
77
63
  type: :runtime
78
64
  prerelease: false
79
65
  version_requirements: !ruby/object:Gem::Requirement
80
66
  requirements:
81
67
  - - ">="
82
68
  - !ruby/object:Gem::Version
83
- version: '5.0'
69
+ version: 7.0.0
84
70
  - - "<"
85
71
  - !ruby/object:Gem::Version
86
- version: '7.0'
72
+ version: 8.0.0
87
73
  - !ruby/object:Gem::Dependency
88
74
  name: thor
89
75
  requirement: !ruby/object:Gem::Requirement
90
76
  requirements:
91
77
  - - ">="
92
78
  - !ruby/object:Gem::Version
93
- version: '0.20'
79
+ version: '1.0'
94
80
  - - "<"
95
81
  - !ruby/object:Gem::Version
96
82
  version: '3.0'
@@ -100,7 +86,7 @@ dependencies:
100
86
  requirements:
101
87
  - - ">="
102
88
  - !ruby/object:Gem::Version
103
- version: '0.20'
89
+ version: '1.0'
104
90
  - - "<"
105
91
  - !ruby/object:Gem::Version
106
92
  version: '3.0'
@@ -151,7 +137,6 @@ files:
151
137
  - lib/sidekiq_unique_jobs/lock_info.rb
152
138
  - lib/sidekiq_unique_jobs/lock_timeout.rb
153
139
  - lib/sidekiq_unique_jobs/lock_ttl.rb
154
- - lib/sidekiq_unique_jobs/lock_type.rb
155
140
  - lib/sidekiq_unique_jobs/locksmith.rb
156
141
  - lib/sidekiq_unique_jobs/logging.rb
157
142
  - lib/sidekiq_unique_jobs/logging/middleware_context.rb
@@ -233,33 +218,7 @@ licenses:
233
218
  - MIT
234
219
  metadata:
235
220
  rubygems_mfa_required: 'true'
236
- post_install_message: |
237
- IMPORTANT!
238
-
239
- Automatic configuration of the sidekiq middleware is no longer done.
240
- Please see: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/master/README.md#add-the-middleware
241
-
242
- This version deprecated the following sidekiq_options
243
-
244
- - sidekiq_options lock_args: :method_name
245
-
246
- It is now configured with:
247
-
248
- - sidekiq_options lock_args_method: :method_name
249
-
250
- This is also true for `Sidekiq.default_worker_options`
251
-
252
- We also deprecated the global configuration options:
253
- - default_lock_ttl
254
- - default_lock_ttl=
255
- - default_lock_timeout
256
- - default_lock_timeout=
257
-
258
- The new methods to use are:
259
- - lock_ttl
260
- - lock_ttl=
261
- - lock_timeout
262
- - lock_timeout=
221
+ post_install_message:
263
222
  rdoc_options: []
264
223
  require_paths:
265
224
  - lib
@@ -267,14 +226,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
267
226
  requirements:
268
227
  - - ">="
269
228
  - !ruby/object:Gem::Version
270
- version: '2.5'
229
+ version: '2.7'
271
230
  required_rubygems_version: !ruby/object:Gem::Requirement
272
231
  requirements:
273
232
  - - ">="
274
233
  - !ruby/object:Gem::Version
275
234
  version: '0'
276
235
  requirements: []
277
- rubygems_version: 3.5.6
236
+ rubygems_version: 3.4.2
278
237
  signing_key:
279
238
  specification_version: 4
280
239
  summary: Sidekiq middleware that prevents duplicates jobs
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SidekiqUniqueJobs
4
- # Calculates the lock type
5
- #
6
- class LockType
7
- # includes "SidekiqUniqueJobs::SidekiqWorkerMethods"
8
- # @!parse include SidekiqUniqueJobs::SidekiqWorkerMethods
9
- include SidekiqUniqueJobs::SidekiqWorkerMethods
10
-
11
- #
12
- # Computes lock type from job arguments, sidekiq_options.
13
- #
14
- # @return [Symbol] the lock type
15
- # @return [NilClass] if no lock type is found.
16
- #
17
- def self.call(item)
18
- new(item).call
19
- end
20
-
21
- # @!attribute [r] item
22
- # @return [Hash] the Sidekiq job hash
23
- attr_reader :item
24
-
25
- # @param [Hash] item the Sidekiq job hash
26
- # @option item [Symbol, nil] :lock the type of lock to use.
27
- # @option item [String] :class the class of the sidekiq worker
28
- def initialize(item)
29
- @item = item
30
- self.job_class = item[CLASS]
31
- end
32
-
33
- def call
34
- item[LOCK] || job_options[LOCK] || default_job_options[LOCK]
35
- end
36
- end
37
- end