sidekiq-unique-jobs 7.0.0.beta22 → 7.0.0.beta27

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 (80) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +88 -15
  3. data/README.md +55 -30
  4. data/lib/sidekiq_unique_jobs.rb +0 -1
  5. data/lib/sidekiq_unique_jobs/batch_delete.rb +1 -1
  6. data/lib/sidekiq_unique_jobs/changelog.rb +1 -1
  7. data/lib/sidekiq_unique_jobs/cli.rb +4 -2
  8. data/lib/sidekiq_unique_jobs/connection.rb +1 -1
  9. data/lib/sidekiq_unique_jobs/constants.rb +4 -1
  10. data/lib/sidekiq_unique_jobs/digests.rb +1 -1
  11. data/lib/sidekiq_unique_jobs/exceptions.rb +9 -9
  12. data/lib/sidekiq_unique_jobs/job.rb +5 -5
  13. data/lib/sidekiq_unique_jobs/json.rb +1 -1
  14. data/lib/sidekiq_unique_jobs/key.rb +1 -1
  15. data/lib/sidekiq_unique_jobs/lock.rb +1 -1
  16. data/lib/sidekiq_unique_jobs/lock/base_lock.rb +1 -1
  17. data/lib/sidekiq_unique_jobs/lock/client_validator.rb +1 -1
  18. data/lib/sidekiq_unique_jobs/lock/server_validator.rb +1 -1
  19. data/lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb +1 -1
  20. data/lib/sidekiq_unique_jobs/lock/until_executed.rb +1 -1
  21. data/lib/sidekiq_unique_jobs/lock/until_executing.rb +1 -1
  22. data/lib/sidekiq_unique_jobs/lock/until_expired.rb +1 -1
  23. data/lib/sidekiq_unique_jobs/lock/validator.rb +3 -2
  24. data/lib/sidekiq_unique_jobs/lock/while_executing.rb +1 -1
  25. data/lib/sidekiq_unique_jobs/lock/while_executing_reject.rb +1 -1
  26. data/lib/sidekiq_unique_jobs/lock_args.rb +4 -4
  27. data/lib/sidekiq_unique_jobs/lock_config.rb +5 -5
  28. data/lib/sidekiq_unique_jobs/lock_digest.rb +2 -2
  29. data/lib/sidekiq_unique_jobs/lock_info.rb +1 -1
  30. data/lib/sidekiq_unique_jobs/lock_timeout.rb +1 -1
  31. data/lib/sidekiq_unique_jobs/lock_ttl.rb +1 -1
  32. data/lib/sidekiq_unique_jobs/locksmith.rb +1 -1
  33. data/lib/sidekiq_unique_jobs/logging.rb +3 -3
  34. data/lib/sidekiq_unique_jobs/logging/middleware_context.rb +2 -2
  35. data/lib/sidekiq_unique_jobs/lua/delete_by_digest.lua +1 -1
  36. data/lib/sidekiq_unique_jobs/lua/shared/_delete_from_queue.lua +3 -0
  37. data/lib/sidekiq_unique_jobs/middleware.rb +16 -4
  38. data/lib/sidekiq_unique_jobs/middleware/client.rb +5 -5
  39. data/lib/sidekiq_unique_jobs/middleware/server.rb +3 -3
  40. data/lib/sidekiq_unique_jobs/normalizer.rb +1 -1
  41. data/lib/sidekiq_unique_jobs/on_conflict.rb +1 -1
  42. data/lib/sidekiq_unique_jobs/on_conflict/log.rb +1 -1
  43. data/lib/sidekiq_unique_jobs/on_conflict/null_strategy.rb +1 -1
  44. data/lib/sidekiq_unique_jobs/on_conflict/raise.rb +1 -1
  45. data/lib/sidekiq_unique_jobs/on_conflict/reject.rb +1 -1
  46. data/lib/sidekiq_unique_jobs/on_conflict/replace.rb +1 -1
  47. data/lib/sidekiq_unique_jobs/on_conflict/reschedule.rb +1 -1
  48. data/lib/sidekiq_unique_jobs/on_conflict/strategy.rb +1 -1
  49. data/lib/sidekiq_unique_jobs/options_with_fallback.rb +1 -1
  50. data/lib/sidekiq_unique_jobs/orphans/lua_reaper.rb +1 -1
  51. data/lib/sidekiq_unique_jobs/orphans/manager.rb +35 -4
  52. data/lib/sidekiq_unique_jobs/orphans/null_reaper.rb +24 -0
  53. data/lib/sidekiq_unique_jobs/orphans/observer.rb +2 -2
  54. data/lib/sidekiq_unique_jobs/orphans/reaper.rb +5 -1
  55. data/lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb +5 -5
  56. data/lib/sidekiq_unique_jobs/profiler.rb +1 -1
  57. data/lib/sidekiq_unique_jobs/redis.rb +1 -1
  58. data/lib/sidekiq_unique_jobs/redis/entity.rb +1 -1
  59. data/lib/sidekiq_unique_jobs/redis/hash.rb +1 -1
  60. data/lib/sidekiq_unique_jobs/redis/list.rb +1 -1
  61. data/lib/sidekiq_unique_jobs/redis/set.rb +1 -1
  62. data/lib/sidekiq_unique_jobs/redis/sorted_set.rb +1 -1
  63. data/lib/sidekiq_unique_jobs/redis/string.rb +1 -1
  64. data/lib/sidekiq_unique_jobs/rspec/matchers.rb +2 -2
  65. data/lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb +2 -2
  66. data/lib/sidekiq_unique_jobs/script.rb +1 -1
  67. data/lib/sidekiq_unique_jobs/script/caller.rb +2 -2
  68. data/lib/sidekiq_unique_jobs/sidekiq_unique_ext.rb +5 -5
  69. data/lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb +1 -1
  70. data/lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb +9 -3
  71. data/lib/sidekiq_unique_jobs/testing.rb +2 -1
  72. data/lib/sidekiq_unique_jobs/timing.rb +1 -1
  73. data/lib/sidekiq_unique_jobs/unlockable.rb +1 -1
  74. data/lib/sidekiq_unique_jobs/update_version.rb +1 -1
  75. data/lib/sidekiq_unique_jobs/upgrade_locks.rb +1 -1
  76. data/lib/sidekiq_unique_jobs/version.rb +1 -1
  77. data/lib/sidekiq_unique_jobs/version_check.rb +23 -4
  78. data/lib/sidekiq_unique_jobs/web.rb +1 -1
  79. data/lib/sidekiq_unique_jobs/web/helpers.rb +1 -1
  80. metadata +19 -6
@@ -3,10 +3,11 @@
3
3
  #
4
4
  # Module with constants to avoid string duplication
5
5
  #
6
- # @author Mikael Henriksson <mikael@zoolutions.se>
6
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
7
7
  #
8
8
  module SidekiqUniqueJobs
9
9
  ARGS ||= "args"
10
+ APARTMENT ||= "apartment"
10
11
  AT ||= "at"
11
12
  CHANGELOGS ||= "uniquejobs:changelog"
12
13
  CLASS ||= "class"
@@ -18,6 +19,7 @@ module SidekiqUniqueJobs
18
19
  LIVE_VERSION ||= "uniquejobs:live"
19
20
  LOCK ||= "lock"
20
21
  LOCK_ARGS ||= "lock_args"
22
+ LOCK_ARGS_METHOD ||= "lock_args_method"
21
23
  LOCK_DIGEST ||= "lock_digest"
22
24
  LOCK_EXPIRATION ||= "lock_expiration"
23
25
  LOCK_INFO ||= "lock_info"
@@ -42,6 +44,7 @@ module SidekiqUniqueJobs
42
44
  UNIQUE_ACROSS_QUEUES ||= "unique_across_queues"
43
45
  UNIQUE_ACROSS_WORKERS ||= "unique_across_workers"
44
46
  UNIQUE_ARGS ||= "unique_args"
47
+ UNIQUE_ARGS_METHOD ||= "unique_args_method"
45
48
  UNIQUE_DIGEST ||= "unique_digest"
46
49
  UNIQUE_PREFIX ||= "unique_prefix"
47
50
  UNIQUE_REAPER ||= "uniquejobs:reaper"
@@ -4,7 +4,7 @@ module SidekiqUniqueJobs
4
4
  #
5
5
  # Class Changelogs provides access to the changelog entries
6
6
  #
7
- # @author Mikael Henriksson <mikael@zoolutions.se>
7
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
8
8
  #
9
9
  class Digests < Redis::SortedSet
10
10
  #
@@ -4,14 +4,14 @@ module SidekiqUniqueJobs
4
4
  #
5
5
  # Base class for all exceptions raised from the gem
6
6
  #
7
- # @author Mikael Henriksson <mikael@zoolutions.se>
7
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
8
8
  #
9
9
  class UniqueJobsError < ::RuntimeError
10
10
  end
11
11
 
12
12
  # Error raised when a Lua script fails to execute
13
13
  #
14
- # @author Mikael Henriksson <mikael@zoolutions.se>
14
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
15
15
  class Conflict < UniqueJobsError
16
16
  def initialize(item)
17
17
  super("Item with the key: #{item[LOCK_DIGEST]} is already scheduled or processing")
@@ -21,7 +21,7 @@ module SidekiqUniqueJobs
21
21
  #
22
22
  # Error raised when trying to add a duplicate lock
23
23
  #
24
- # @author Mikael Henriksson <mikael@zoolutions.se>
24
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
25
25
  #
26
26
  class DuplicateLock < UniqueJobsError
27
27
  end
@@ -29,7 +29,7 @@ module SidekiqUniqueJobs
29
29
  #
30
30
  # Error raised when trying to add a duplicate stragegy
31
31
  #
32
- # @author Mikael Henriksson <mikael@zoolutions.se>
32
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
33
33
  #
34
34
  class DuplicateStrategy < UniqueJobsError
35
35
  end
@@ -37,7 +37,7 @@ module SidekiqUniqueJobs
37
37
  #
38
38
  # Error raised when an invalid argument is given
39
39
  #
40
- # @author Mikael Henriksson <mikael@zoolutions.se>
40
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
41
41
  #
42
42
  class InvalidArgument < UniqueJobsError
43
43
  end
@@ -45,7 +45,7 @@ module SidekiqUniqueJobs
45
45
  #
46
46
  # Raised when a workers configuration is invalid
47
47
  #
48
- # @author Mikael Henriksson <mikael@zoolutions.se>
48
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
49
49
  #
50
50
  class InvalidWorker < UniqueJobsError
51
51
  def initialize(lock_config)
@@ -58,7 +58,7 @@ module SidekiqUniqueJobs
58
58
 
59
59
  # Error raised when a Lua script fails to execute
60
60
  #
61
- # @author Mikael Henriksson <mikael@zoolutions.se>
61
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
62
62
  class InvalidUniqueArguments < UniqueJobsError
63
63
  def initialize(options)
64
64
  given = options[:given]
@@ -79,7 +79,7 @@ module SidekiqUniqueJobs
79
79
  #
80
80
  # Raised when a workers configuration is invalid
81
81
  #
82
- # @author Mikael Henriksson <mikael@zoolutions.se>
82
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
83
83
  #
84
84
  class NotUniqueWorker < UniqueJobsError
85
85
  def initialize(options)
@@ -89,7 +89,7 @@ module SidekiqUniqueJobs
89
89
 
90
90
  # Error raised from {OptionsWithFallback#lock_class}
91
91
  #
92
- # @author Mikael Henriksson <mikael@zoolutions.se>
92
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
93
93
  class UnknownLock < UniqueJobsError
94
94
  end
95
95
  end
@@ -3,7 +3,7 @@
3
3
  module SidekiqUniqueJobs
4
4
  # Utility class to append uniqueness to the sidekiq job hash
5
5
  #
6
- # @author Mikael Henriksson <mikael@zoolutions.se>
6
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
7
7
  module Job
8
8
  extend self
9
9
 
@@ -40,19 +40,19 @@ module SidekiqUniqueJobs
40
40
  end
41
41
 
42
42
  def add_lock_timeout(item)
43
- item[LOCK_TIMEOUT] = SidekiqUniqueJobs::LockTimeout.calculate(item)
43
+ item[LOCK_TIMEOUT] ||= SidekiqUniqueJobs::LockTimeout.calculate(item)
44
44
  end
45
45
 
46
46
  def add_lock_args(item)
47
- item[LOCK_ARGS] = SidekiqUniqueJobs::LockArgs.call(item)
47
+ item[LOCK_ARGS] ||= SidekiqUniqueJobs::LockArgs.call(item)
48
48
  end
49
49
 
50
50
  def add_lock_digest(item)
51
- item[LOCK_DIGEST] = SidekiqUniqueJobs::LockDigest.call(item)
51
+ item[LOCK_DIGEST] ||= SidekiqUniqueJobs::LockDigest.call(item)
52
52
  end
53
53
 
54
54
  def add_lock_prefix(item)
55
- item[LOCK_PREFIX] = SidekiqUniqueJobs.config.unique_prefix
55
+ item[LOCK_PREFIX] ||= SidekiqUniqueJobs.config.unique_prefix
56
56
  end
57
57
  end
58
58
  end
@@ -3,7 +3,7 @@
3
3
  module SidekiqUniqueJobs
4
4
  # Handles loading and dumping of json
5
5
  #
6
- # @author Mikael Henriksson <mikael@zoolutions.se>
6
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
7
7
  module JSON
8
8
  module_function
9
9
 
@@ -3,7 +3,7 @@
3
3
  module SidekiqUniqueJobs
4
4
  # Key class wraps logic dealing with various lock keys
5
5
  #
6
- # @author Mikael Henriksson <mikael@zoolutions.se>
6
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
7
7
  class Key
8
8
  #
9
9
  # @!attribute [r] digest
@@ -4,7 +4,7 @@ module SidekiqUniqueJobs
4
4
  #
5
5
  # Class Lock provides access to information about a lock
6
6
  #
7
- # @author Mikael Henriksson <mikael@zoolutions.se>
7
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
8
8
  #
9
9
  class Lock # rubocop:disable Metrics/ClassLength
10
10
  # includes "SidekiqUniqueJobs::Connection"
@@ -5,7 +5,7 @@ module SidekiqUniqueJobs
5
5
  # Abstract base class for locks
6
6
  #
7
7
  # @abstract
8
- # @author Mikael Henriksson <mikael@zoolutions.se>
8
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
9
9
  class BaseLock
10
10
  include SidekiqUniqueJobs::Logging
11
11
 
@@ -5,7 +5,7 @@ module SidekiqUniqueJobs
5
5
  #
6
6
  # Validates the sidekiq options for the Sidekiq client process
7
7
  #
8
- # @author Mikael Henriksson <mikael@zoolutions.se>
8
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
9
9
  #
10
10
  class ClientValidator
11
11
  #
@@ -5,7 +5,7 @@ module SidekiqUniqueJobs
5
5
  #
6
6
  # Validates the sidekiq options for the Sidekiq server process
7
7
  #
8
- # @author Mikael Henriksson <mikael@zoolutions.se>
8
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
9
9
  #
10
10
  class ServerValidator
11
11
  #
@@ -11,7 +11,7 @@ module SidekiqUniqueJobs
11
11
  # See {#lock} for more information about the client.
12
12
  # See {#execute} for more information about the server
13
13
  #
14
- # @author Mikael Henriksson <mikael@zoolutions.se>
14
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
15
15
  class UntilAndWhileExecuting < BaseLock
16
16
  # Executes in the Sidekiq server process
17
17
  # @yield to the worker class perform method
@@ -6,7 +6,7 @@ module SidekiqUniqueJobs
6
6
  # - Locks on perform_in or perform_async
7
7
  # - Unlocks after yielding to the worker's perform method
8
8
  #
9
- # @author Mikael Henriksson <mikael@zoolutions.se>
9
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
10
10
  class UntilExecuted < BaseLock
11
11
  OK ||= "OK"
12
12
 
@@ -6,7 +6,7 @@ module SidekiqUniqueJobs
6
6
  # - Locks on perform_in or perform_async
7
7
  # - Unlocks before yielding to the worker's perform method
8
8
  #
9
- # @author Mikael Henriksson <mikael@zoolutions.se>
9
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
10
10
  class UntilExecuting < BaseLock
11
11
  # Executes in the Sidekiq server process
12
12
  # @yield to the worker class perform method
@@ -5,7 +5,7 @@ module SidekiqUniqueJobs
5
5
  #
6
6
  # UntilExpired locks until the job expires
7
7
  #
8
- # @author Mikael Henriksson <mikael@zoolutions.se>
8
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
9
9
  #
10
10
  class UntilExpired < UntilExecuted
11
11
  end
@@ -5,14 +5,15 @@ module SidekiqUniqueJobs
5
5
  #
6
6
  # Validator base class to avoid some duplication
7
7
  #
8
- # @author Mikael Henriksson <mikael@zoolutions.se>
8
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
9
9
  #
10
10
  class Validator
11
11
  #
12
12
  # @return [Hash] a hash mapping of deprecated keys and their new value
13
13
  DEPRECATED_KEYS = {
14
14
  UNIQUE.to_sym => LOCK.to_sym,
15
- UNIQUE_ARGS.to_sym => LOCK_ARGS.to_sym,
15
+ UNIQUE_ARGS.to_sym => LOCK_ARGS_METHOD.to_sym,
16
+ LOCK_ARGS.to_sym => LOCK_ARGS_METHOD.to_sym,
16
17
  UNIQUE_PREFIX.to_sym => LOCK_PREFIX.to_sym,
17
18
  }.freeze
18
19
 
@@ -9,7 +9,7 @@ module SidekiqUniqueJobs
9
9
  # See {#lock} for more information about the client.
10
10
  # See {#execute} for more information about the server
11
11
  #
12
- # @author Mikael Henriksson <mikael@zoolutions.se>
12
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
13
13
  class WhileExecuting < BaseLock
14
14
  RUN_SUFFIX ||= ":RUN"
15
15
 
@@ -9,7 +9,7 @@ module SidekiqUniqueJobs
9
9
  # See {#lock} for more information about the client.
10
10
  # See {#execute} for more information about the server
11
11
  #
12
- # @author Mikael Henriksson <mikael@zoolutions.se>
12
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
13
13
  class WhileExecutingReject < WhileExecuting
14
14
  # Overridden with a forced {OnConflict::Reject} strategy
15
15
  # @return [OnConflict::Reject] a reject strategy
@@ -3,7 +3,7 @@
3
3
  module SidekiqUniqueJobs
4
4
  # Handles uniqueness of sidekiq arguments
5
5
  #
6
- # @author Mikael Henriksson <mikael@zoolutions.se>
6
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
7
7
  class LockArgs
8
8
  include SidekiqUniqueJobs::Logging
9
9
  include SidekiqUniqueJobs::SidekiqWorkerMethods
@@ -98,7 +98,7 @@ module SidekiqUniqueJobs
98
98
 
99
99
  # The method to use for filtering unique arguments
100
100
  def lock_args_method
101
- @lock_args_method ||= worker_options[LOCK_ARGS] || worker_options[UNIQUE_ARGS]
101
+ @lock_args_method ||= worker_options.slice(LOCK_ARGS_METHOD, UNIQUE_ARGS_METHOD).values.first
102
102
  @lock_args_method ||= :lock_args if worker_method_defined?(:lock_args)
103
103
  @lock_args_method ||= :unique_args if worker_method_defined?(:unique_args)
104
104
  @lock_args_method ||= default_lock_args_method
@@ -106,8 +106,8 @@ module SidekiqUniqueJobs
106
106
 
107
107
  # The global worker options defined in Sidekiq directly
108
108
  def default_lock_args_method
109
- default_worker_options[LOCK_ARGS] ||
110
- default_worker_options[UNIQUE_ARGS]
109
+ default_worker_options[LOCK_ARGS_METHOD] ||
110
+ default_worker_options[UNIQUE_ARGS_METHOD]
111
111
  end
112
112
 
113
113
  #
@@ -5,7 +5,7 @@ module SidekiqUniqueJobs
5
5
  # Gathers all configuration for a lock
6
6
  # which helps reduce the amount of instance variables
7
7
  #
8
- # @author Mikael Henriksson <mikael@zoolutions.se>
8
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
9
9
  #
10
10
  class LockConfig
11
11
  #
@@ -59,12 +59,12 @@ module SidekiqUniqueJobs
59
59
  def initialize(job_hash = {})
60
60
  @type = job_hash[LOCK]&.to_sym
61
61
  @worker = job_hash[CLASS]
62
- @limit = job_hash.fetch(LOCK_LIMIT) { 1 }
63
- @timeout = job_hash.fetch(LOCK_TIMEOUT) { 0 }
64
- @ttl = job_hash.fetch(LOCK_TTL) { job_hash.fetch(LOCK_EXPIRATION) { nil } }.to_i
62
+ @limit = job_hash.fetch(LOCK_LIMIT, 1)
63
+ @timeout = job_hash.fetch(LOCK_TIMEOUT, 0)
64
+ @ttl = job_hash.fetch(LOCK_TTL) { job_hash.fetch(LOCK_EXPIRATION, nil) }.to_i
65
65
  @pttl = ttl * 1_000
66
66
  @lock_info = job_hash.fetch(LOCK_INFO) { SidekiqUniqueJobs.config.lock_info }
67
- @on_conflict = job_hash.fetch(ON_CONFLICT) { nil }
67
+ @on_conflict = job_hash.fetch(ON_CONFLICT, nil)
68
68
  @errors = job_hash.fetch(ERRORS) { {} }
69
69
 
70
70
  @on_client_conflict = job_hash[ON_CLIENT_CONFLICT]
@@ -5,7 +5,7 @@ require "openssl"
5
5
  module SidekiqUniqueJobs
6
6
  # Handles uniqueness of sidekiq arguments
7
7
  #
8
- # @author Mikael Henriksson <mikael@zoolutions.se>
8
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
9
9
  class LockDigest
10
10
  include SidekiqUniqueJobs::Logging
11
11
  include SidekiqUniqueJobs::JSON
@@ -58,7 +58,7 @@ module SidekiqUniqueJobs
58
58
  # Filter a hash to use for digest
59
59
  # @return [Hash] to use for digest
60
60
  def digestable_hash
61
- @item.slice(CLASS, QUEUE, LOCK_ARGS).tap do |hash|
61
+ @item.slice(CLASS, QUEUE, LOCK_ARGS, APARTMENT).tap do |hash|
62
62
  hash.delete(QUEUE) if unique_across_queues?
63
63
  hash.delete(CLASS) if unique_across_workers?
64
64
  end
@@ -4,7 +4,7 @@ module SidekiqUniqueJobs
4
4
  #
5
5
  # Class Info provides information about a lock
6
6
  #
7
- # @author Mikael Henriksson <mikael@zoolutions.se>
7
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
8
8
  #
9
9
  class LockInfo < Redis::String
10
10
  #
@@ -3,7 +3,7 @@
3
3
  module SidekiqUniqueJobs
4
4
  # Calculates timeout and expiration
5
5
  #
6
- # @author Mikael Henriksson <mikael@zoolutions.se>
6
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
7
7
  class LockTimeout
8
8
  # includes "SidekiqUniqueJobs::SidekiqWorkerMethods"
9
9
  # @!parse include SidekiqUniqueJobs::SidekiqWorkerMethods
@@ -3,7 +3,7 @@
3
3
  module SidekiqUniqueJobs
4
4
  # Calculates timeout and expiration
5
5
  #
6
- # @author Mikael Henriksson <mikael@zoolutions.se>
6
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
7
7
  class LockTTL
8
8
  # includes "SidekiqUniqueJobs::SidekiqWorkerMethods"
9
9
  # @!parse include SidekiqUniqueJobs::SidekiqWorkerMethods
@@ -3,7 +3,7 @@
3
3
  module SidekiqUniqueJobs
4
4
  # Lock manager class that handles all the various locks
5
5
  #
6
- # @author Mikael Henriksson <mikael@zoolutions.se>
6
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
7
7
  class Locksmith # rubocop:disable Metrics/ClassLength
8
8
  # includes "SidekiqUniqueJobs::Connection"
9
9
  # @!parse include SidekiqUniqueJobs::Connection
@@ -3,7 +3,7 @@
3
3
  module SidekiqUniqueJobs
4
4
  # Utility module for reducing the number of uses of logger.
5
5
  #
6
- # @author Mikael Henriksson <mikael@zoolutions.se>
6
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
7
7
  module Logging
8
8
  def self.included(base)
9
9
  base.send(:extend, self)
@@ -114,8 +114,8 @@ module SidekiqUniqueJobs
114
114
  #
115
115
  # @yield
116
116
  #
117
- def with_configured_loggers_context
118
- logger_method.call(logging_context) { yield }
117
+ def with_configured_loggers_context(&block)
118
+ logger_method.call(logging_context, &block)
119
119
  end
120
120
 
121
121
  #
@@ -4,13 +4,13 @@ module SidekiqUniqueJobs
4
4
  #
5
5
  # Provides the sidekiq middleware that makes the gem work
6
6
  #
7
- # @author Mikael Henriksson <mikael@zoolutions.se>
7
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
8
8
  #
9
9
  module Logging
10
10
  #
11
11
  # Context aware logging for Sidekiq Middlewares
12
12
  #
13
- # @author Mikael Henriksson <mikael@zoolutions.se>
13
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
14
14
  #
15
15
  module Middleware
16
16
  include Logging
@@ -25,7 +25,7 @@ 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"
28
+ local del_cmd = "DEL"
29
29
 
30
30
  log_debug("BEGIN delete_by_digest:", digest)
31
31
 
@@ -6,6 +6,9 @@ local function delete_from_queue(queue, digest)
6
6
 
7
7
  while (index < total) do
8
8
  local items = redis.call("LRANGE", queue, index, index + per -1)
9
+ if #items == 0 then
10
+ break
11
+ end
9
12
  for _, item in pairs(items) do
10
13
  if string.find(item, digest) then
11
14
  redis.call("LREM", queue, 1, item)