sidekiq-unique-jobs 7.1.30 → 8.0.3

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.

Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +50 -2
  3. data/README.md +11 -11
  4. data/lib/sidekiq_unique_jobs/batch_delete.rb +1 -5
  5. data/lib/sidekiq_unique_jobs/changelog.rb +4 -14
  6. data/lib/sidekiq_unique_jobs/connection.rb +4 -7
  7. data/lib/sidekiq_unique_jobs/digests.rb +2 -12
  8. data/lib/sidekiq_unique_jobs/job.rb +1 -1
  9. data/lib/sidekiq_unique_jobs/lock.rb +5 -2
  10. data/lib/sidekiq_unique_jobs/locksmith.rb +4 -12
  11. data/lib/sidekiq_unique_jobs/lua/delete.lua +3 -6
  12. data/lib/sidekiq_unique_jobs/lua/delete_by_digest.lua +3 -6
  13. data/lib/sidekiq_unique_jobs/lua/delete_job_by_digest.lua +1 -1
  14. data/lib/sidekiq_unique_jobs/lua/find_digest_in_queues.lua +1 -1
  15. data/lib/sidekiq_unique_jobs/lua/lock.lua +1 -1
  16. data/lib/sidekiq_unique_jobs/lua/lock_until_expired.lua +1 -1
  17. data/lib/sidekiq_unique_jobs/lua/locked.lua +1 -1
  18. data/lib/sidekiq_unique_jobs/lua/queue.lua +1 -1
  19. data/lib/sidekiq_unique_jobs/lua/reap_orphans.lua +3 -6
  20. data/lib/sidekiq_unique_jobs/lua/shared/_common.lua +0 -5
  21. data/lib/sidekiq_unique_jobs/lua/shared/_delete_from_sorted_set.lua +1 -0
  22. data/lib/sidekiq_unique_jobs/lua/unlock.lua +7 -10
  23. data/lib/sidekiq_unique_jobs/lua/update_version.lua +1 -1
  24. data/lib/sidekiq_unique_jobs/lua/upgrade.lua +1 -3
  25. data/lib/sidekiq_unique_jobs/on_conflict/reject.rb +0 -43
  26. data/lib/sidekiq_unique_jobs/orphans/manager.rb +1 -1
  27. data/lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb +4 -8
  28. data/lib/sidekiq_unique_jobs/redis/sorted_set.rb +9 -2
  29. data/lib/sidekiq_unique_jobs/reflections.rb +1 -1
  30. data/lib/sidekiq_unique_jobs/script/caller.rb +14 -8
  31. data/lib/sidekiq_unique_jobs/server.rb +0 -1
  32. data/lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb +1 -1
  33. data/lib/sidekiq_unique_jobs/upgrade_locks.rb +7 -10
  34. data/lib/sidekiq_unique_jobs/version.rb +1 -1
  35. data/lib/sidekiq_unique_jobs/web/helpers.rb +4 -2
  36. data/lib/sidekiq_unique_jobs/web/views/changelogs.erb +44 -38
  37. data/lib/sidekiq_unique_jobs/web/views/locks.erb +42 -37
  38. data/lib/sidekiq_unique_jobs/web.rb +6 -7
  39. data/lib/sidekiq_unique_jobs.rb +1 -1
  40. metadata +10 -50
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8fec809cda45f395d8eed686c8b2ac69d59c332d04dc1a4968d66aa03b521c04
4
- data.tar.gz: da85dc0ef4b155d3baec392d11230f7f59955ee617c1459cfaba4455e1cd4a17
3
+ metadata.gz: 2462acb2448a07c45eb8a1789239f859a09e079cff316fe61dc205d9ea8856a4
4
+ data.tar.gz: 57449a594cd034c79001815883806098e04a92869c41cbe6044c90ab6f1fa3ae
5
5
  SHA512:
6
- metadata.gz: 6df2fccd762fe81f71ce9fa20d3e413ff2b4147bac2d10f2bcfbe479d420b895fe888050f8f3f980bfeee693448c052d12e9c78b5ecd524c96277e29d4277685
7
- data.tar.gz: c60f92fdd29a4f37f5903776108f11e0c3ea1e04c5d2462700d5ee01ad57d1cdd5b20fa725ed662f95c873663ce04d932f6c90267b0cea631095285f57324de3
6
+ metadata.gz: b200d3544047b6080147b19b71ffd83a0ac42087ed29f1d84fb35b226b1418f50e37c94b309a946504c32d26b11b5fd173ade85e77c568931d33b948f1c656f9
7
+ data.tar.gz: 9d12cbf3317acd4e5bd6d934616622e5ac3336ecba4e51b2b29fbf6782deab2b1af291af1471e16da7271fef42b33804b7a3c7f3475016de88bd75e2d0668684
data/CHANGELOG.md CHANGED
@@ -1,8 +1,56 @@
1
1
  # Changelog
2
2
 
3
- ## [Unreleased](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/HEAD)
3
+ ## [v8.0.2](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v8.0.2) (2023-03-13)
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/v8.0.1...v8.0.2)
6
+
7
+ **Closed issues:**
8
+
9
+ - Missing v7.1 branch? [\#757](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/757)
10
+ - Allow one running job but at most one job in the queue [\#748](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/748)
11
+
12
+ **Merged pull requests:**
13
+
14
+ - update debug\_lua check to match passed in arg type [\#765](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/765) ([JeremiahChurch](https://github.com/JeremiahChurch))
15
+ - fix rubocop [\#764](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/764) ([JeremiahChurch](https://github.com/JeremiahChurch))
16
+ - Hide lock info debug suggestion on lock page if it's already enabled. [\#763](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/763) ([JeremiahChurch](https://github.com/JeremiahChurch))
17
+ - fix lock & changelog times on web interface [\#762](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/762) ([JeremiahChurch](https://github.com/JeremiahChurch))
18
+
19
+ ## [v8.0.1](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v8.0.1) (2023-02-14)
20
+
21
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v8.0.0...v8.0.1)
22
+
23
+ **Closed issues:**
24
+
25
+ - TypeError: Unsupported command argument type: ActiveSupport::Duration [\#754](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/754)
26
+ - Incompatibility with Sidekiq 7 [\#736](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/736)
27
+
28
+ **Merged pull requests:**
29
+
30
+ - Fix active worker detection by using correct keys [\#756](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/756) ([dodo121](https://github.com/dodo121))
31
+ - Fix minor typo in drift\_reaper\_interval comment [\#755](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/755) ([lazyatom](https://github.com/lazyatom))
32
+
33
+ ## [v8.0.0](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v8.0.0) (2023-01-30)
34
+
35
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.1.29...v8.0.0)
36
+
37
+ **Implemented enhancements:**
38
+
39
+ - chore\(deps\): upgrade rails app [\#753](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/753) ([mhenrixon](https://github.com/mhenrixon))
40
+ - feat: sidekiq v7 support [\#751](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/751) ([mhenrixon](https://github.com/mhenrixon))
41
+
42
+ **Closed issues:**
43
+
44
+ - Support for redis 5 [\#752](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/752)
45
+ - while\_executing jobs being dropped [\#749](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/749)
46
+
47
+ **Merged pull requests:**
48
+
49
+ - fix: backport the fix for the return value of \#deep\_transform\_keys [\#750](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/750) ([fixtheclouds](https://github.com/fixtheclouds))
50
+
51
+ ## [v7.1.29](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.1.29) (2022-12-03)
52
+
53
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.1.28...v7.1.29)
6
54
 
7
55
  **Fixed bugs:**
8
56
 
data/README.md CHANGED
@@ -45,11 +45,11 @@ Want to show me some ❤️ for the hard work I do on this gem? You can use the
45
45
  - [reschedule_failed](#reschedule_failed)
46
46
  - [rescheduled](#rescheduled)
47
47
  - [timeout](#timeout)
48
- - [unlock_failed](#unlock_failed)
49
- - [unlocked](#unlocked)
50
- - [unknown_sidekiq_worker](#unknown_sidekiq_worker)
51
- - [Show Locks](#show-locks)
52
- - [Show Lock](#show-lock)
48
+ - [unlock_failed](#unlock_failed)
49
+ - [unlocked](#unlocked)
50
+ - [unknown_sidekiq_worker](#unknown_sidekiq_worker)
51
+ - [Show Locks](#show-locks)
52
+ - [Show Lock](#show-lock)
53
53
  - [Testing](#testing)
54
54
  - [Validating Worker Configuration](#validating-worker-configuration)
55
55
  - [Uniqueness](#uniqueness)
@@ -545,23 +545,23 @@ For when a job was successfully rescheduled
545
545
 
546
546
  This is also mostly useful for reporting/metrics purposes. What this reflection does is signal that the job was configured to wait (`lock_timeout` was configured), but we couldn't retrieve a lock even though we waited for some time.
547
547
 
548
- ### unlock_failed
548
+ #### unlock_failed
549
549
 
550
- This is not got, this is worth
550
+ This means that the server middleware could not unlock your job and the lock is kept (potentially preventing subsequent jobs from being pushed or processed).
551
551
 
552
- ### unlocked
552
+ #### unlocked
553
553
 
554
554
  Also mostly useful for reporting purposes. The job was successfully unlocked.
555
555
 
556
- ### unknown_sidekiq_worker
556
+ #### unknown_sidekiq_worker
557
557
 
558
558
  The reason this happens is that the server couldn't find a valid sidekiq worker class. Most likely, that worker isn't intended to be processed by this sidekiq server instance.
559
559
 
560
- #### Show Locks
560
+ ### Show Locks
561
561
 
562
562
  ![Locks](assets/unique_digests_1.png)
563
563
 
564
- #### Show Lock
564
+ ### Show Lock
565
565
 
566
566
  ![Lock](assets/unique_digests_2.png)
567
567
 
@@ -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
@@ -7,7 +7,7 @@ module SidekiqUniqueJobs
7
7
  module Job
8
8
  extend self
9
9
 
10
- # Adds timeout, expiration, lock_args, lock_prefix and lock_digest to the sidekiq job hash
10
+ # Adds lock, timeout, expiration, lock_args, lock_prefix, and lock_digest to the sidekiq job hash
11
11
  # @return [Hash] the job hash
12
12
  def prepare(item)
13
13
  stringify_on_conflict_hash(item)
@@ -46,8 +46,11 @@ module SidekiqUniqueJobs
46
46
  # @param [Timstamp, Float] time nil optional timestamp to initiate this lock with
47
47
  #
48
48
  def initialize(key, time: nil)
49
- @key = get_key(key)
50
- @created_at = time.is_a?(Float) ? time : time.to_f
49
+ @key = get_key(key)
50
+ time = time.is_a?(Float) ? time : time.to_f
51
+ return unless time.nonzero?
52
+
53
+ @created_at = time
51
54
  end
52
55
 
53
56
  #
@@ -243,7 +243,7 @@ module SidekiqUniqueJobs
243
243
  # @return [nil] when lock was not possible
244
244
  # @return [Object] whatever the block returns when lock was acquired
245
245
  #
246
- def primed_async(conn, wait = nil, &block)
246
+ def primed_async(conn, wait = nil, &block) # rubocop:disable Metrics/MethodLength
247
247
  timeout = (wait || config.timeout).to_i
248
248
  timeout = 1 if timeout.zero?
249
249
 
@@ -308,22 +308,14 @@ module SidekiqUniqueJobs
308
308
  # passing timeout 0 to brpoplpush causes it to block indefinitely
309
309
  raise InvalidArgument, "wait must be an integer" unless wait.is_a?(Integer)
310
310
 
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
311
+ conn.blmove(key.queued, key.primed, "RIGHT", "LEFT", wait)
320
312
  end
321
313
 
322
314
  #
323
315
  # @api private
324
316
  #
325
317
  def rpoplpush(conn)
326
- conn.rpoplpush(key.queued, key.primed)
318
+ conn.lmove(key.queued, key.primed, "RIGHT", "LEFT")
327
319
  end
328
320
 
329
321
  #
@@ -366,7 +358,7 @@ module SidekiqUniqueJobs
366
358
  # @return [true, false]
367
359
  #
368
360
  def taken?(conn)
369
- conn.hexists(key.locked, job_id)
361
+ conn.hexists(key.locked, job_id) != 0
370
362
  end
371
363
 
372
364
  def argv
@@ -17,7 +17,7 @@ local limit = tonumber(ARGV[4])
17
17
 
18
18
  -------- BEGIN injected arguments --------
19
19
  local current_time = tonumber(ARGV[5])
20
- local debug_lua = tostring(ARGV[6]) == "true"
20
+ local debug_lua = tostring(ARGV[6]) == "1"
21
21
  local max_history = tonumber(ARGV[7])
22
22
  local script_name = tostring(ARGV[8]) .. ".lua"
23
23
  local redisversion = tostring(ARGV[9])
@@ -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")
@@ -12,7 +12,7 @@ local digests = KEYS[9]
12
12
 
13
13
  -------- BEGIN injected arguments --------
14
14
  local current_time = tonumber(ARGV[1])
15
- local debug_lua = ARGV[2] == "true"
15
+ local debug_lua = tostring(ARGV[2]) == "1"
16
16
  local max_history = tonumber(ARGV[3])
17
17
  local script_name = tostring(ARGV[4]) .. ".lua"
18
18
  local redisversion = tostring(ARGV[5])
@@ -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)
@@ -10,7 +10,7 @@ local digest = ARGV[1]
10
10
 
11
11
  -------- BEGIN injected arguments --------
12
12
  local current_time = tonumber(ARGV[2])
13
- local debug_lua = ARGV[3] == "true"
13
+ local debug_lua = tostring(ARGV[3]) == "1"
14
14
  local max_history = tonumber(ARGV[4])
15
15
  local script_name = tostring(ARGV[5]) .. ".lua"
16
16
  --------- END injected arguments ---------
@@ -4,7 +4,7 @@ local digest = KEYS[1]
4
4
 
5
5
  -------- BEGIN injected arguments --------
6
6
  local current_time = tonumber(ARGV[2])
7
- local debug_lua = ARGV[3] == "true"
7
+ local debug_lua = tostring(ARGV[3]) == "1"
8
8
  local max_history = tonumber(ARGV[4])
9
9
  local script_name = tostring(ARGV[5]) .. ".lua"
10
10
  --------- END injected arguments ---------
@@ -20,7 +20,7 @@ local limit = tonumber(ARGV[4])
20
20
 
21
21
  -------- BEGIN injected arguments --------
22
22
  local current_time = tonumber(ARGV[5])
23
- local debug_lua = ARGV[6] == "true"
23
+ local debug_lua = tostring(ARGV[6]) == "1"
24
24
  local max_history = tonumber(ARGV[7])
25
25
  local script_name = tostring(ARGV[8]) .. ".lua"
26
26
  local redisversion = ARGV[9]
@@ -20,7 +20,7 @@ local limit = tonumber(ARGV[4])
20
20
 
21
21
  -------- BEGIN injected arguments --------
22
22
  local current_time = tonumber(ARGV[5])
23
- local debug_lua = ARGV[6] == "true"
23
+ local debug_lua = tostring(ARGV[6]) == "1"
24
24
  local max_history = tonumber(ARGV[7])
25
25
  local script_name = tostring(ARGV[8]) .. ".lua"
26
26
  local redisversion = ARGV[9]
@@ -14,7 +14,7 @@ local job_id = ARGV[1]
14
14
 
15
15
  -------- BEGIN injected arguments --------
16
16
  local current_time = tonumber(ARGV[2])
17
- local debug_lua = ARGV[3] == "true"
17
+ local debug_lua = tostring(ARGV[3]) == "1"
18
18
  local max_history = tonumber(ARGV[4])
19
19
  local script_name = tostring(ARGV[5]) .. ".lua"
20
20
  --------- END injected arguments ---------
@@ -19,7 +19,7 @@ local limit = tonumber(ARGV[4])
19
19
 
20
20
  -------- BEGIN injected arguments --------
21
21
  local current_time = tonumber(ARGV[5])
22
- local debug_lua = ARGV[6] == "true"
22
+ local debug_lua = tostring(ARGV[6]) == "1"
23
23
  local max_history = tonumber(ARGV[7])
24
24
  local script_name = tostring(ARGV[8]) .. ".lua"
25
25
  --------- END injected arguments ---------
@@ -14,7 +14,7 @@ local threshold = tonumber(ARGV[2])
14
14
 
15
15
  -------- BEGIN injected arguments --------
16
16
  local current_time = tonumber(ARGV[3])
17
- local debug_lua = ARGV[4] == "true"
17
+ local debug_lua = tostring(ARGV[4]) == "1"
18
18
  local max_history = tonumber(ARGV[5])
19
19
  local script_name = ARGV[6] .. ".lua"
20
20
  local redisversion = ARGV[7]
@@ -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
@@ -9,11 +9,6 @@ local function toversion(version)
9
9
  }
10
10
  end
11
11
 
12
- local function toboolean(val)
13
- val = tostring(val)
14
- return val == "1" or val == "true"
15
- end
16
-
17
12
  local function log_debug( ... )
18
13
  if debug_lua ~= true then return end
19
14
 
@@ -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
@@ -19,7 +19,7 @@ local limit = tonumber(ARGV[4])
19
19
 
20
20
  -------- BEGIN injected arguments --------
21
21
  local current_time = tonumber(ARGV[5])
22
- local debug_lua = ARGV[6] == "true"
22
+ local debug_lua = tostring(ARGV[6]) == "1"
23
23
  local max_history = tonumber(ARGV[7])
24
24
  local script_name = tostring(ARGV[8]) .. ".lua"
25
25
  local redisversion = ARGV[9]
@@ -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
@@ -9,7 +9,7 @@ local version = ARGV[1]
9
9
 
10
10
  -------- BEGIN injected arguments --------
11
11
  local current_time = tonumber(ARGV[2])
12
- local debug_lua = ARGV[3] == "true"
12
+ local debug_lua = tostring(ARGV[3]) == "1"
13
13
  local max_history = tonumber(ARGV[4])
14
14
  local script_name = tostring(ARGV[5]) .. ".lua"
15
15
  --------- END injected arguments ---------
@@ -6,7 +6,7 @@ local dead_version = KEYS[2]
6
6
 
7
7
  -------- BEGIN injected arguments --------
8
8
  local current_time = tonumber(ARGV[5])
9
- local debug_lua = ARGV[6] == "true"
9
+ local debug_lua = tostring(ARGV[6]) == "1"
10
10
  local max_history = tonumber(ARGV[7])
11
11
  local script_name = tostring(ARGV[8]) .. ".lua"
12
12
  local redisversion = ARGV[9]
@@ -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
  #
@@ -217,7 +217,7 @@ module SidekiqUniqueJobs
217
217
 
218
218
  #
219
219
  # Reaper interval with a little drift
220
- # Redis isn't exact enough so to give a little bufffer,
220
+ # Redis isn't exact enough so to give a little buffer,
221
221
  # we add a tiny value to the reaper interval.
222
222
  #
223
223
  #
@@ -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|
@@ -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
@@ -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
  #
@@ -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.30"
6
+ VERSION = "8.0.3"
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
  #
@@ -146,6 +146,8 @@ module SidekiqUniqueJobs
146
146
  # @return [String] a html safe string with relative time information
147
147
  #
148
148
  def safe_relative_time(time)
149
+ return unless time
150
+
149
151
  time = parse_time(time)
150
152
 
151
153
  relative_time(time)
@@ -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><%= safe_relative_time(changelog['time']) || "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,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
@@ -17,8 +16,8 @@ module SidekiqUniqueJobs
17
16
  @filter = params[:filter] || "*"
18
17
  @filter = "*" if @filter == ""
19
18
  @count = (params[:count] || 100).to_i
20
- @current_cursor = params[:cursor]
21
- @prev_cursor = params[:prev_cursor]
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,
@@ -37,8 +36,8 @@ module SidekiqUniqueJobs
37
36
  @filter = params[:filter] || "*"
38
37
  @filter = "*" if @filter == ""
39
38
  @count = (params[:count] || 100).to_i
40
- @current_cursor = params[:cursor]
41
- @prev_cursor = params[:prev_cursor]
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,
@@ -53,8 +52,8 @@ module SidekiqUniqueJobs
53
52
  @filter = params[:filter] || "*"
54
53
  @filter = "*" if @filter == ""
55
54
  @count = (params[:count] || 100).to_i
56
- @current_cursor = params[:cursor]
57
- @prev_cursor = params[:prev_cursor]
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,
@@ -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"
@@ -50,6 +49,7 @@ require "sidekiq_unique_jobs/cli"
50
49
  require "sidekiq_unique_jobs/core_ext"
51
50
  require "sidekiq_unique_jobs/lock_timeout"
52
51
  require "sidekiq_unique_jobs/lock_ttl"
52
+ require "sidekiq_unique_jobs/lock_type"
53
53
  require "sidekiq_unique_jobs/lock_args"
54
54
  require "sidekiq_unique_jobs/lock_digest"
55
55
  require "sidekiq_unique_jobs/unlockable"
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.30
4
+ version: 8.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-17 00:00:00.000000000 Z
11
+ date: 2023-07-10 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'
@@ -233,33 +219,7 @@ licenses:
233
219
  - MIT
234
220
  metadata:
235
221
  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=
222
+ post_install_message:
263
223
  rdoc_options: []
264
224
  require_paths:
265
225
  - lib
@@ -267,7 +227,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
267
227
  requirements:
268
228
  - - ">="
269
229
  - !ruby/object:Gem::Version
270
- version: '2.5'
230
+ version: '2.7'
271
231
  required_rubygems_version: !ruby/object:Gem::Requirement
272
232
  requirements:
273
233
  - - ">="