sidekiq-unique-jobs 7.0.0.beta19 → 7.0.0.beta24

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: 0533eff22c876bdbba1624e7bd997a0bfaa1254fe372bfc24fc67c95d2001eaf
4
- data.tar.gz: 8bf21d326a04268bab7b4981af462649724a9e1ea5d312cdc5fe1e58b23f40d7
3
+ metadata.gz: cbd7bb8a58fe7319fb013de48e8c3914bb66157bb447b7186adaa9e936d1975e
4
+ data.tar.gz: 79e21055189827adeb3e8dadffe4ad86b75c464e5261731532e599278c3a154e
5
5
  SHA512:
6
- metadata.gz: 645799c00a61c3665c63eaf77203c20db9220188aa757a19799a1f1863a8949fc2e8a71e023d8f3b39f3583534d74903dc39a7c6926c0c7ec37fa16ee61d9801
7
- data.tar.gz: 5da81c81bd550d9181190d583aa742d4ee65cc2a7a470ce5f7d3e595b74244ac9af39757900f9a7d7ecee0792f27022679080cde87b5c202c50b495b011e3727
6
+ metadata.gz: 83bdc216d7b13aefc6cb168a175e6fda8974ae9fbbe356505889b20f1ed358b297d4fbe1fd8cb67ad5e393a332db764b81d58a9978508fd7cfe6ce0b83f49ff3
7
+ data.tar.gz: ea3b0d0681a700f434b4204ddad09374b22375365c4bf7532a5a56fe70b9e08d1a4a6bcc38dfae2f91efb60d00553a13c942e0737b5fb1b1fc0124f38c1f9c2b
@@ -1,5 +1,59 @@
1
1
  # Changelog
2
2
 
3
+ ## [Unreleased](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/HEAD)
4
+
5
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta22...HEAD)
6
+
7
+ **Closed issues:**
8
+
9
+ - Ruby reaper incorrectly checks active jobs — removes every active lock as result [\#517](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/517)
10
+
11
+ ## [v7.0.0.beta22](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta22) (2020-06-12)
12
+
13
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta21...v7.0.0.beta22)
14
+
15
+ **Fixed bugs:**
16
+
17
+ - Infinite loop in ruby reaper [\#515](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/515)
18
+ - Prevent reaping of active jobs [\#518](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/518) ([mhenrixon](https://github.com/mhenrixon))
19
+
20
+ ## [v7.0.0.beta21](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta21) (2020-06-12)
21
+
22
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta20...v7.0.0.beta21)
23
+
24
+ **Implemented enhancements:**
25
+
26
+ - Move gems to gemfile [\#513](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/513) ([mhenrixon](https://github.com/mhenrixon))
27
+ - Move dev-gems from gemspec to gemfile [\#512](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/512) ([mhenrixon](https://github.com/mhenrixon))
28
+
29
+ **Fixed bugs:**
30
+
31
+ - Prevent indefinitely looping entries [\#516](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/516) ([mhenrixon](https://github.com/mhenrixon))
32
+
33
+ **Closed issues:**
34
+
35
+ - Missing web interface [\#514](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/514)
36
+
37
+ ## [v7.0.0.beta20](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta20) (2020-06-02)
38
+
39
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta19...v7.0.0.beta20)
40
+
41
+ **Fixed bugs:**
42
+
43
+ - Reaper can't be registered again if sidekiq gets killed by SIGKILL [\#490](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/490)
44
+
45
+ **Closed issues:**
46
+
47
+ - How do I turn this on for only one job class? [\#510](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/510)
48
+
49
+ ## [v7.0.0.beta19](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta19) (2020-05-21)
50
+
51
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta18...v7.0.0.beta19)
52
+
53
+ **Fixed bugs:**
54
+
55
+ - Expire reaper when not checking in [\#508](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/508) ([mhenrixon](https://github.com/mhenrixon))
56
+
3
57
  ## [v7.0.0.beta18](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta18) (2020-05-21)
4
58
 
5
59
  [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta17...v7.0.0.beta18)
@@ -641,7 +695,6 @@
641
695
  **Implemented enhancements:**
642
696
 
643
697
  - Prepare for v6 [\#286](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/286) ([mhenrixon](https://github.com/mhenrixon))
644
- - Only unlock not delete [\#285](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/285) ([mhenrixon](https://github.com/mhenrixon))
645
698
 
646
699
  ## [v6.0.0.rc3](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v6.0.0.rc3) (2018-06-29)
647
700
 
@@ -659,6 +712,7 @@
659
712
 
660
713
  - Within tests: workers enqueued in the future don't clear their unique locks after being drained/executed [\#254](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/254)
661
714
  - Unexpected behavior with until\_executed [\#250](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/250)
715
+ - Only unlock not delete [\#285](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/285) ([mhenrixon](https://github.com/mhenrixon))
662
716
 
663
717
  **Fixed bugs:**
664
718
 
@@ -708,6 +762,7 @@
708
762
  - Code smells [\#275](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/275) ([mhenrixon](https://github.com/mhenrixon))
709
763
  - Reject while scheduling [\#273](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/273) ([mhenrixon](https://github.com/mhenrixon))
710
764
  - Improve testing [\#272](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/272) ([mhenrixon](https://github.com/mhenrixon))
765
+ - Solidify master [\#270](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/270) ([mhenrixon](https://github.com/mhenrixon))
711
766
 
712
767
  ## [v6.0.0.beta](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v6.0.0.beta) (2018-06-17)
713
768
 
@@ -716,7 +771,6 @@
716
771
  **Implemented enhancements:**
717
772
 
718
773
  - Until and while executing [\#271](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/271) ([mhenrixon](https://github.com/mhenrixon))
719
- - Solidify master [\#270](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/270) ([mhenrixon](https://github.com/mhenrixon))
720
774
  - Minor adjustments [\#268](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/268) ([mhenrixon](https://github.com/mhenrixon))
721
775
  - Use ruby 2.5.1 [\#267](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/267) ([mhenrixon](https://github.com/mhenrixon))
722
776
  - Add explicit concurrent-ruby dependency. [\#265](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/265) ([brettburley](https://github.com/brettburley))
@@ -877,6 +931,7 @@
877
931
  - Increase sleep delay in WhileExecuting\#synchronize [\#204](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/204) ([dsander](https://github.com/dsander))
878
932
  - Ensure job ID removed from uniquejobs hash [\#200](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/200) ([carlosmartinez](https://github.com/carlosmartinez))
879
933
  - unique args need to be an array [\#194](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/194) ([pboling](https://github.com/pboling))
934
+ - fix for \#168. Handle the NOSCRIPT by sending the script again [\#178](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/178) ([otzy007](https://github.com/otzy007))
880
935
 
881
936
  ## [v4.0.18](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v4.0.18) (2016-07-24)
882
937
 
@@ -899,7 +954,6 @@
899
954
 
900
955
  - missed space [\#188](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/188) ([TheBigSadowski](https://github.com/TheBigSadowski))
901
956
  - Convert unless if to just 1 if [\#179](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/179) ([otzy007](https://github.com/otzy007))
902
- - fix for \#168. Handle the NOSCRIPT by sending the script again [\#178](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/178) ([otzy007](https://github.com/otzy007))
903
957
  - Fixed gitter badge link [\#176](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/176) ([andrew](https://github.com/andrew))
904
958
 
905
959
  ## [v4.0.17](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v4.0.17) (2016-03-02)
@@ -1001,7 +1055,6 @@
1001
1055
  **Merged pull requests:**
1002
1056
 
1003
1057
  - Calculate worker's unique args when a proc or a symbol is specified [\#143](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/143) ([zeqfreed](https://github.com/zeqfreed))
1004
- - Fix markdown link formatting [\#134](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/134) ([thbar](https://github.com/thbar))
1005
1058
 
1006
1059
  ## [v4.0.7](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v4.0.7) (2015-10-14)
1007
1060
 
@@ -1032,6 +1085,7 @@
1032
1085
 
1033
1086
  **Merged pull requests:**
1034
1087
 
1088
+ - Fix markdown link formatting [\#134](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/134) ([thbar](https://github.com/thbar))
1035
1089
  - Forces to look for testing namespace in Sidekiq and not his ancestors [\#129](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/129) ([antek-drzewiecki](https://github.com/antek-drzewiecki))
1036
1090
  - Fix outdated phrasing and add test coverage to readme [\#123](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/123) ([albertyw](https://github.com/albertyw))
1037
1091
 
data/README.md CHANGED
@@ -562,17 +562,22 @@ If you need to perform any additional work after the lock has been released you
562
562
  **Exception 1:** UntilExecuting unlocks and uses callback before yielding.
563
563
  **Exception 2:** UntilExpired expires eventually, no after_unlock hook is called.
564
564
 
565
+ **NOTE:** _It is also possible to write this code as a class method._
566
+
565
567
  ```ruby
566
568
  class UniqueJobWithFilterMethod
567
569
  include Sidekiq::Worker
568
570
  sidekiq_options lock: :while_executing,
569
571
 
572
+ def self.after_unlock
573
+ # block has yielded and lock is released
574
+ end
575
+
570
576
  def after_unlock
571
577
  # block has yielded and lock is released
572
578
  end
573
579
  ...
574
580
  end.
575
- ```
576
581
 
577
582
  ### Logging
578
583
 
@@ -26,7 +26,6 @@ require "sidekiq_unique_jobs/connection"
26
26
  require "sidekiq_unique_jobs/exceptions"
27
27
  require "sidekiq_unique_jobs/script"
28
28
  require "sidekiq_unique_jobs/script/caller"
29
- require "sidekiq_unique_jobs/json"
30
29
  require "sidekiq_unique_jobs/normalizer"
31
30
  require "sidekiq_unique_jobs/job"
32
31
  require "sidekiq_unique_jobs/redis"
@@ -40,7 +40,7 @@ module SidekiqUniqueJobs
40
40
  options[:count] = count if count
41
41
 
42
42
  redis do |conn|
43
- conn.zscan_each(key, options).to_a.map { |entry| load_json(entry[0]) }
43
+ conn.zscan_each(key, **options).to_a.map { |entry| load_json(entry[0]) }
44
44
  end
45
45
  end
46
46
 
@@ -10,7 +10,7 @@ module SidekiqUniqueJobs
10
10
  #
11
11
  class Cli < Thor
12
12
  # :nodoc:
13
- def self.banner(command, _namespace = nil, _subcommand = false)
13
+ def self.banner(command, _namespace = nil, _subcommand = false) # rubocop:disable Style/OptionalBooleanParameter
14
14
  "jobs #{@package_name} #{command.usage}" # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
15
15
  end
16
16
 
@@ -80,7 +80,7 @@ module SidekiqUniqueJobs
80
80
  options[:match] = pattern
81
81
  options[:count] = count if count
82
82
 
83
- result = redis { |conn| conn.zscan_each(key, options).to_a }
83
+ result = redis { |conn| conn.zscan_each(key, **options).to_a }
84
84
 
85
85
  result.each_with_object({}) do |entry, hash|
86
86
  hash[entry[0]] = entry[1]
@@ -63,7 +63,6 @@ module SidekiqUniqueJobs
63
63
  # @return [Array] args unfiltered when neither of the above
64
64
  def filtered_args
65
65
  return args if lock_args_disabled?
66
- return args if args.empty?
67
66
 
68
67
  json_args = Normalizer.jsonify(args)
69
68
 
@@ -98,7 +97,7 @@ module SidekiqUniqueJobs
98
97
  end
99
98
 
100
99
  # The method to use for filtering unique arguments
101
- def lock_args_method
100
+ def lock_args_method # rubocop:disable Metrics/CyclomaticComplexity
102
101
  @lock_args_method ||= worker_options[LOCK_ARGS] || worker_options[UNIQUE_ARGS]
103
102
  @lock_args_method ||= :lock_args if worker_method_defined?(:lock_args)
104
103
  @lock_args_method ||= :unique_args if worker_method_defined?(:unique_args)
@@ -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]
@@ -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
  #
@@ -65,11 +65,7 @@ repeat
65
65
  -- TODO: Add check for jobs checked out by process
66
66
  if found ~= true then
67
67
  log_debug("Searching for digest:", digest, "in process sets")
68
- local queue = find_digest_in_process_set(digest)
69
- if queue then
70
- log_debug("found digest:", digest, "in queue:", queue)
71
- found = true
72
- end
68
+ found = find_digest_in_process_set(digest)
73
69
  end
74
70
 
75
71
  if found ~= true then
@@ -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)
@@ -4,7 +4,7 @@ local function find_digest_in_process_set(digest)
4
4
  local pattern = "*" .. digest .. "*"
5
5
  local found = false
6
6
 
7
- log_debug("searching in list processes:",
7
+ log_debug("Searching in process list",
8
8
  "for digest:", digest,
9
9
  "cursor:", process_cursor)
10
10
 
@@ -15,15 +15,26 @@ local function find_digest_in_process_set(digest)
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 .. ":workers"
18
19
  log_debug("searching in process set:", process,
19
20
  "for digest:", digest,
20
21
  "cursor:", process_cursor)
21
22
 
22
- local job = redis.call("HGET", process, "info")
23
+ local jobs = redis.call("HGETALL", workers_key)
23
24
 
24
- if string.find(job, digest) then
25
- log_debug("Found digest", digest, "in process:", process)
26
- found = true
25
+ if #jobs == 0 then
26
+ log_debug("No entries in:", workers_key)
27
+ else
28
+ for i = 1, #jobs, 2 do
29
+ if string.find(jobs[i +1], digest) then
30
+ log_debug("Found digest", digest, "in:", workers_key)
31
+ found = true
32
+ break
33
+ end
34
+ end
35
+ end
36
+
37
+ if found == true then
27
38
  break
28
39
  end
29
40
  end
@@ -18,15 +18,15 @@ module SidekiqUniqueJobs
18
18
  #
19
19
  # @yield when uniqueness is disable
20
20
  # @yield when the lock is successful
21
- def call(*)
22
- lock { yield }
21
+ def call(*, &block)
22
+ lock(&block)
23
23
  end
24
24
 
25
25
  private
26
26
 
27
27
  def lock
28
- if (token = lock_instance.lock)
29
- yield token
28
+ if (_token = lock_instance.lock)
29
+ yield
30
30
  else
31
31
  warn_about_duplicate
32
32
  end
@@ -19,8 +19,8 @@ module SidekiqUniqueJobs
19
19
  #
20
20
  # @yield when uniqueness is disabled
21
21
  # @yield when owning the lock
22
- def call(*)
23
- lock_instance.execute { yield }
22
+ def call(*, &block)
23
+ lock_instance.execute(&block)
24
24
  end
25
25
  end
26
26
  end
@@ -111,7 +111,7 @@ module SidekiqUniqueJobs
111
111
  # @return [String] a JSON formatted string
112
112
  #
113
113
  def payload
114
- @payload ||= Sidekiq.dump_json(item)
114
+ @payload ||= dump_json(item)
115
115
  end
116
116
  end
117
117
  end
@@ -117,17 +117,24 @@ module SidekiqUniqueJobs
117
117
  end
118
118
  end
119
119
 
120
- def active?(digest)
120
+ def active?(digest) # rubocop:disable Metrics/MethodLength
121
121
  Sidekiq.redis do |conn|
122
- procs = conn.sscan_each("processes").to_a.sort
122
+ procs = conn.sscan_each("processes").to_a
123
+ return false if procs.empty?
123
124
 
124
- result = conn.pipelined do
125
- procs.map do |key|
126
- conn.hget(key, "info")
125
+ procs.sort.each do |key|
126
+ valid, workers = conn.pipelined do
127
+ conn.exists(key)
128
+ conn.hgetall("#{key}:workers")
127
129
  end
128
- end
129
130
 
130
- result.flatten.compact.any? { |job| load_json(job)[LOCK_DIGEST] == digest }
131
+ next unless valid
132
+ next unless workers.any?
133
+
134
+ workers.each_pair do |_tid, job|
135
+ return true if load_json(job)[LOCK_DIGEST] == digest
136
+ end
137
+ end
131
138
  end
132
139
  end
133
140
 
@@ -144,7 +151,7 @@ module SidekiqUniqueJobs
144
151
  conn.sscan_each("queues", &block)
145
152
  end
146
153
 
147
- def entries(conn, queue) # rubocop:disable Metrics/MethodLength
154
+ def entries(conn, queue, &block) # rubocop:disable Metrics/MethodLength
148
155
  queue_key = "queue:#{queue}"
149
156
  initial_size = conn.llen(queue_key)
150
157
  deleted_size = 0
@@ -157,9 +164,9 @@ module SidekiqUniqueJobs
157
164
  entries = conn.lrange(queue_key, range_start, range_end)
158
165
  page += 1
159
166
 
160
- entries.each do |entry|
161
- yield entry
162
- end
167
+ break if entries.empty?
168
+
169
+ entries.each(&block)
163
170
 
164
171
  deleted_size = initial_size - conn.llen(queue_key)
165
172
  end
@@ -46,7 +46,13 @@ module SidekiqUniqueJobs
46
46
  # @return [false] when not exists
47
47
  #
48
48
  def exist?
49
- redis { |conn| conn.exists(key) }
49
+ redis do |conn|
50
+ value = conn.exists(key)
51
+ return true if value.is_a?(TrueClass)
52
+ return false if value.is_a?(FalseClass)
53
+
54
+ value.positive?
55
+ end
50
56
  end
51
57
 
52
58
  #
@@ -35,7 +35,13 @@ module SidekiqUniqueJobs
35
35
  # The hook to call after a successful unlock
36
36
  # @return [Proc]
37
37
  def after_unlock_hook
38
- -> { worker_class.after_unlock if worker_method_defined?(:after_unlock) }
38
+ lambda do
39
+ if @worker_class.respond_to?(:after_unlock)
40
+ @worker_class.after_unlock # instance method in sidekiq v6
41
+ elsif worker_class.respond_to?(:after_unlock)
42
+ worker_class.after_unlock # class method regardless of sidekiq version
43
+ end
44
+ end
39
45
  end
40
46
 
41
47
  # Attempt to constantize a string worker_class argument, always
@@ -126,7 +126,7 @@ module SidekiqUniqueJobs
126
126
  def batch_scan(match:, count:)
127
127
  cursor = "0"
128
128
  loop do
129
- cursor, values = conn.scan(cursor, match: match, per: count)
129
+ cursor, values = conn.scan(cursor, match: match, count: count)
130
130
  yield values
131
131
  break if cursor == "0"
132
132
  end
@@ -3,5 +3,5 @@
3
3
  module SidekiqUniqueJobs
4
4
  #
5
5
  # @return [String] the current SidekiqUniqueJobs version
6
- VERSION = "7.0.0.beta19"
6
+ VERSION = "7.0.0.beta24"
7
7
  end
@@ -7,10 +7,10 @@ module SidekiqUniqueJobs
7
7
  # @author Mikael Henriksson <mikael@zoolutions.se>
8
8
  #
9
9
  class VersionCheck
10
- PATTERN = /(?<operator1>[<>=]+)?\s?(?<version1>(\d+.?)+)(\s+&&\s+)?(?<operator2>[<>=]+)?\s?(?<version2>(\d+.?)+)?/m.freeze # rubocop:disable Layout/LineLength
10
+ PATTERN = /(?<operator1>[<>=]+)?\s?(?<version1>(\d+.?)+)(\s+&&\s+)?(?<operator2>[<>=]+)?\s?(?<version2>(\d+.?)+)?/m.freeze # rubocop:disable Layout/LineLength, Lint/MixedRegexpCaptureTypes
11
11
 
12
12
  #
13
- # Checks if a version is consrtaint is satisfied
13
+ # Checks if a version is constraint is satisfied
14
14
  #
15
15
  # @example A satisfied constraint
16
16
  # VersionCheck.satisfied?("5.0.0", ">= 4.0.0") #=> true
@@ -22,12 +22,31 @@ module SidekiqUniqueJobs
22
22
  # @param [String] version a version string `5.0.0`
23
23
  # @param [String] constraint a version constraint `>= 5.0.0 <= 5.1.1`
24
24
  #
25
- # @return [<type>] <description>
25
+ # @return [true, false] <description>
26
26
  #
27
27
  def self.satisfied?(version, constraint)
28
28
  new(version, constraint).satisfied?
29
29
  end
30
30
 
31
+ #
32
+ # Checks if a version is constraint is unfulfilled
33
+ #
34
+ # @example A satisfied constraint
35
+ # VersionCheck.unfulfilled?("5.0.0", ">= 4.0.0") #=> false
36
+ #
37
+ # @example An unfulfilled constraint
38
+ # VersionCheck.unfulfilled?("5.0.0", "<= 4.0.0") #=> true
39
+ #
40
+ #
41
+ # @param [String] version a version string `5.0.0`
42
+ # @param [String] constraint a version constraint `>= 5.0.0 <= 5.1.1`
43
+ #
44
+ # @return [true, false] <description>
45
+ #
46
+ def self.unfulfilled?(version, constraint)
47
+ !satisfied?(version, constraint)
48
+ end
49
+
31
50
  #
32
51
  # @!attribute [r] version
33
52
  # @return [String] a version string `5.0.0`
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-unique-jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0.beta19
4
+ version: 7.0.0.beta24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-21 00:00:00.000000000 Z
11
+ date: 2020-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: brpoplpush-redis_script
@@ -90,158 +90,6 @@ dependencies:
90
90
  - - "<"
91
91
  - !ruby/object:Gem::Version
92
92
  version: '2.0'
93
- - !ruby/object:Gem::Dependency
94
- name: bundler
95
- requirement: !ruby/object:Gem::Requirement
96
- requirements:
97
- - - "~>"
98
- - !ruby/object:Gem::Version
99
- version: '2.1'
100
- type: :development
101
- prerelease: false
102
- version_requirements: !ruby/object:Gem::Requirement
103
- requirements:
104
- - - "~>"
105
- - !ruby/object:Gem::Version
106
- version: '2.1'
107
- - !ruby/object:Gem::Dependency
108
- name: rack-test
109
- requirement: !ruby/object:Gem::Requirement
110
- requirements:
111
- - - ">="
112
- - !ruby/object:Gem::Version
113
- version: '1.0'
114
- - - "<"
115
- - !ruby/object:Gem::Version
116
- version: '2.0'
117
- type: :development
118
- prerelease: false
119
- version_requirements: !ruby/object:Gem::Requirement
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- version: '1.0'
124
- - - "<"
125
- - !ruby/object:Gem::Version
126
- version: '2.0'
127
- - !ruby/object:Gem::Dependency
128
- name: rake
129
- requirement: !ruby/object:Gem::Requirement
130
- requirements:
131
- - - "~>"
132
- - !ruby/object:Gem::Version
133
- version: '13.0'
134
- type: :development
135
- prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- requirements:
138
- - - "~>"
139
- - !ruby/object:Gem::Version
140
- version: '13.0'
141
- - !ruby/object:Gem::Dependency
142
- name: rspec
143
- requirement: !ruby/object:Gem::Requirement
144
- requirements:
145
- - - "~>"
146
- - !ruby/object:Gem::Version
147
- version: '3.9'
148
- type: :development
149
- prerelease: false
150
- version_requirements: !ruby/object:Gem::Requirement
151
- requirements:
152
- - - "~>"
153
- - !ruby/object:Gem::Version
154
- version: '3.9'
155
- - !ruby/object:Gem::Dependency
156
- name: sinatra
157
- requirement: !ruby/object:Gem::Requirement
158
- requirements:
159
- - - ">="
160
- - !ruby/object:Gem::Version
161
- version: '2.0'
162
- - - "<"
163
- - !ruby/object:Gem::Version
164
- version: '3.0'
165
- type: :development
166
- prerelease: false
167
- version_requirements: !ruby/object:Gem::Requirement
168
- requirements:
169
- - - ">="
170
- - !ruby/object:Gem::Version
171
- version: '2.0'
172
- - - "<"
173
- - !ruby/object:Gem::Version
174
- version: '3.0'
175
- - !ruby/object:Gem::Dependency
176
- name: timecop
177
- requirement: !ruby/object:Gem::Requirement
178
- requirements:
179
- - - "~>"
180
- - !ruby/object:Gem::Version
181
- version: '0.9'
182
- type: :development
183
- prerelease: false
184
- version_requirements: !ruby/object:Gem::Requirement
185
- requirements:
186
- - - "~>"
187
- - !ruby/object:Gem::Version
188
- version: '0.9'
189
- - !ruby/object:Gem::Dependency
190
- name: github-markup
191
- requirement: !ruby/object:Gem::Requirement
192
- requirements:
193
- - - "~>"
194
- - !ruby/object:Gem::Version
195
- version: '3.0'
196
- type: :development
197
- prerelease: false
198
- version_requirements: !ruby/object:Gem::Requirement
199
- requirements:
200
- - - "~>"
201
- - !ruby/object:Gem::Version
202
- version: '3.0'
203
- - !ruby/object:Gem::Dependency
204
- name: github_changelog_generator
205
- requirement: !ruby/object:Gem::Requirement
206
- requirements:
207
- - - "~>"
208
- - !ruby/object:Gem::Version
209
- version: '1.14'
210
- type: :development
211
- prerelease: false
212
- version_requirements: !ruby/object:Gem::Requirement
213
- requirements:
214
- - - "~>"
215
- - !ruby/object:Gem::Version
216
- version: '1.14'
217
- - !ruby/object:Gem::Dependency
218
- name: yard
219
- requirement: !ruby/object:Gem::Requirement
220
- requirements:
221
- - - "~>"
222
- - !ruby/object:Gem::Version
223
- version: 0.9.18
224
- type: :development
225
- prerelease: false
226
- version_requirements: !ruby/object:Gem::Requirement
227
- requirements:
228
- - - "~>"
229
- - !ruby/object:Gem::Version
230
- version: 0.9.18
231
- - !ruby/object:Gem::Dependency
232
- name: gem-release
233
- requirement: !ruby/object:Gem::Requirement
234
- requirements:
235
- - - "~>"
236
- - !ruby/object:Gem::Version
237
- version: '2.0'
238
- type: :development
239
- prerelease: false
240
- version_requirements: !ruby/object:Gem::Requirement
241
- requirements:
242
- - - "~>"
243
- - !ruby/object:Gem::Version
244
- version: '2.0'
245
93
  description: |
246
94
  Prevents simultaneous Sidekiq jobs with the same unique arguments to run.
247
95
  Highly configurable to suite your specific needs.
@@ -391,8 +239,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
391
239
  - !ruby/object:Gem::Version
392
240
  version: 1.3.1
393
241
  requirements: []
394
- rubygems_version: 3.0.3
395
- signing_key:
242
+ rubygems_version: 3.1.4
243
+ signing_key:
396
244
  specification_version: 4
397
245
  summary: Sidekiq middleware that prevents duplicates jobs
398
246
  test_files: []