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

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 820d13b5365e9a4af437b1fecaebec61f4c07656b6aa77e49fff21186abc9088
4
- data.tar.gz: 0b90028e6697ec459ff63094e063100878080ad4a18101a60b7682a554c9b5f6
3
+ metadata.gz: 2462acb2448a07c45eb8a1789239f859a09e079cff316fe61dc205d9ea8856a4
4
+ data.tar.gz: 57449a594cd034c79001815883806098e04a92869c41cbe6044c90ab6f1fa3ae
5
5
  SHA512:
6
- metadata.gz: e1e24f2c8921566adc9339841d0ef4931f2768bf7acb207eb680cc84b11bb3671749325996c563e6a5aeb699cda33553597c6dec3451a5028c2bb83e292b82f5
7
- data.tar.gz: ff870dba5ef353df17aa80ad82c58418daef5a7643d1ff6c9bece90e4d57acacdd1091fd2893e88c0e5459a14668344cfb05d9ef3640d5c25eda1650f87f2f4c
6
+ metadata.gz: b200d3544047b6080147b19b71ffd83a0ac42087ed29f1d84fb35b226b1418f50e37c94b309a946504c32d26b11b5fd173ade85e77c568931d33b948f1c656f9
7
+ data.tar.gz: 9d12cbf3317acd4e5bd6d934616622e5ac3336ecba4e51b2b29fbf6782deab2b1af291af1471e16da7271fef42b33804b7a3c7f3475016de88bd75e2d0668684
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## [v8.0.2](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v8.0.2) (2023-03-13)
4
+
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
+
3
19
  ## [v8.0.1](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v8.0.1) (2023-02-14)
4
20
 
5
21
  [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v8.0.0...v8.0.1)
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
 
@@ -7,10 +7,11 @@ 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)
14
+ add_lock_type(item)
14
15
  add_lock_timeout(item)
15
16
  add_lock_ttl(item)
16
17
  add_digest(item)
@@ -54,5 +55,9 @@ module SidekiqUniqueJobs
54
55
  def add_lock_prefix(item)
55
56
  item[LOCK_PREFIX] ||= SidekiqUniqueJobs.config.lock_prefix
56
57
  end
58
+
59
+ def add_lock_type(item)
60
+ item[LOCK] ||= SidekiqUniqueJobs::LockType.call(item)
61
+ end
57
62
  end
58
63
  end
@@ -35,6 +35,7 @@ module SidekiqUniqueJobs
35
35
  def execute
36
36
  executed = locksmith.execute do
37
37
  yield
38
+ ensure
38
39
  unlock_and_callback
39
40
  end
40
41
 
@@ -42,9 +42,8 @@ module SidekiqUniqueJobs
42
42
  with_logging_context do
43
43
  executed = locksmith.execute do
44
44
  yield
45
- callback_safely if locksmith.unlock
46
45
  ensure
47
- locksmith.unlock
46
+ unlock_and_callback
48
47
  end
49
48
 
50
49
  unless executed
@@ -0,0 +1,37 @@
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
@@ -127,7 +127,10 @@ module SidekiqUniqueJobs
127
127
  #
128
128
  def unlock!(conn = nil)
129
129
  call_script(:unlock, key.to_a, argv, conn) do |unlocked_jid|
130
- reflect(:debug, :unlocked, item, unlocked_jid) if unlocked_jid == job_id
130
+ if unlocked_jid == job_id
131
+ reflect(:debug, :unlocked, item, unlocked_jid)
132
+ reflect(:unlocked, item)
133
+ end
131
134
 
132
135
  unlocked_jid
133
136
  end
@@ -312,7 +315,7 @@ module SidekiqUniqueJobs
312
315
  # @api private
313
316
  #
314
317
  def rpoplpush(conn)
315
- conn.rpoplpush(key.queued, key.primed)
318
+ conn.lmove(key.queued, key.primed, "RIGHT", "LEFT")
316
319
  end
317
320
 
318
321
  #
@@ -55,7 +55,7 @@ module SidekiqUniqueJobs
55
55
  # The type of lock for this worker
56
56
  #
57
57
  #
58
- # @return [Symbol]
58
+ # @return [Symbol, NilClass]
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
75
+ @task ||= default_task # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
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
103
+ @task = task # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
104
104
  end
105
105
 
106
106
  #
@@ -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!
20
+ @config ||= reset! # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
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
111
+ @config = SidekiqUniqueJobs::Config.default # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
112
112
  end
113
113
 
114
114
  #
@@ -288,7 +288,7 @@ module SidekiqUniqueJobs # rubocop:disable Metrics/ModuleLength
288
288
  # @return [Reflections]
289
289
  #
290
290
  def reflections
291
- @reflections ||= Reflections.new
291
+ @reflections ||= Reflections.new # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
292
292
  end
293
293
 
294
294
  #
@@ -3,5 +3,5 @@
3
3
  module SidekiqUniqueJobs
4
4
  #
5
5
  # @return [String] the current SidekiqUniqueJobs version
6
- VERSION = "8.0.2"
6
+ VERSION = "8.0.3"
7
7
  end
@@ -49,6 +49,7 @@ require "sidekiq_unique_jobs/cli"
49
49
  require "sidekiq_unique_jobs/core_ext"
50
50
  require "sidekiq_unique_jobs/lock_timeout"
51
51
  require "sidekiq_unique_jobs/lock_ttl"
52
+ require "sidekiq_unique_jobs/lock_type"
52
53
  require "sidekiq_unique_jobs/lock_args"
53
54
  require "sidekiq_unique_jobs/lock_digest"
54
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: 8.0.2
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-03-13 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
@@ -137,6 +137,7 @@ files:
137
137
  - lib/sidekiq_unique_jobs/lock_info.rb
138
138
  - lib/sidekiq_unique_jobs/lock_timeout.rb
139
139
  - lib/sidekiq_unique_jobs/lock_ttl.rb
140
+ - lib/sidekiq_unique_jobs/lock_type.rb
140
141
  - lib/sidekiq_unique_jobs/locksmith.rb
141
142
  - lib/sidekiq_unique_jobs/logging.rb
142
143
  - lib/sidekiq_unique_jobs/logging/middleware_context.rb
@@ -233,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
234
  - !ruby/object:Gem::Version
234
235
  version: '0'
235
236
  requirements: []
236
- rubygems_version: 3.4.7
237
+ rubygems_version: 3.4.15
237
238
  signing_key:
238
239
  specification_version: 4
239
240
  summary: Sidekiq middleware that prevents duplicates jobs