sidekiq-unique-jobs 7.0.0.beta20 → 7.0.0.beta25

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: eb9187151e279ce0c7d654c62b86c57d3ae6ba21639206050943b72032df9f03
4
- data.tar.gz: 54aaf4e5179a445ebc551705a68ea177c7cc16c29f5e06d3d8287a683176c58b
3
+ metadata.gz: 616316456566100190d005a5173bd3e9aa0f5558182d9e5e9965ecffde4aea65
4
+ data.tar.gz: bc35728df95960b932af55737c358df8d3a18a0d5c9798d944f0f386113a35d0
5
5
  SHA512:
6
- metadata.gz: 7c0c34048dd03e862038d92f2b092b03102593899f1c9b30f290dc8ef6a960b67b7583ae82e84d40d69cc001eff1342bb4c7092abfdb6269e8bc8adae2752c79
7
- data.tar.gz: 22ea78f67d06a986f3accc92799d83f1c18cba92d4ca2f2a1cebb386d902f6f4105bcd52e4a4235388748c95edca0efa7befe622ed24d25ab509ad4281bc9ced
6
+ metadata.gz: 9d3a8b690a6599d7ad0d4a9dc249aa32ab193efb41fcb4ab37825f2921376af863e8949f51341e1fccb97628213d4aa0dd215d6442c030771593b7ad9f99cc2e
7
+ data.tar.gz: 2a25c29067a417bdc244dfecfc9777d8c195edc98ede3367be7a93d364191f30cdd012056fe70570739e45122a9ba6d7b2a8247b5ea414b238aa7eaa1d561d33
@@ -1,13 +1,73 @@
1
1
  # Changelog
2
2
 
3
- ## [Unreleased](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/HEAD)
3
+ ## [v7.0.0.beta24](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta24) (2020-09-27)
4
4
 
5
- [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta19...HEAD)
5
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta23...v7.0.0.beta24)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Support both instance method and class method [\#527](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/527) ([mhenrixon](https://github.com/mhenrixon))
10
+
11
+ **Closed issues:**
12
+
13
+ - while\_executing + raise let non-unique jobs to be executed [\#534](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/534)
14
+ - Leaked keys in version 5.0.10 [\#519](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/519)
15
+
16
+ ## [v7.0.0.beta23](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta23) (2020-06-23)
17
+
18
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v6.0.23...v7.0.0.beta23)
19
+
20
+ **Fixed bugs:**
21
+
22
+ - Exit early when no results are returned from LRANGE given jobs might already processed [\#521](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/521) ([vipulnsward](https://github.com/vipulnsward))
23
+
24
+ ## [v6.0.23](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v6.0.23) (2020-06-23)
25
+
26
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta22...v6.0.23)
27
+
28
+ **Fixed bugs:**
29
+
30
+ - Ruby reaper incorrectly checks active jobs — removes every active lock as result [\#517](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/517)
31
+ - Backport \#465 to 6.x series [\#520](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/520) ([replaid](https://github.com/replaid))
32
+
33
+ ## [v7.0.0.beta22](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta22) (2020-06-12)
34
+
35
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta21...v7.0.0.beta22)
36
+
37
+ **Fixed bugs:**
38
+
39
+ - Infinite loop in ruby reaper [\#515](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/515)
40
+ - Prevent reaping of active jobs [\#518](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/518) ([mhenrixon](https://github.com/mhenrixon))
41
+
42
+ ## [v7.0.0.beta21](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta21) (2020-06-12)
43
+
44
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta20...v7.0.0.beta21)
45
+
46
+ **Implemented enhancements:**
47
+
48
+ - Move gems to gemfile [\#513](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/513) ([mhenrixon](https://github.com/mhenrixon))
49
+ - Move dev-gems from gemspec to gemfile [\#512](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/512) ([mhenrixon](https://github.com/mhenrixon))
50
+
51
+ **Fixed bugs:**
52
+
53
+ - Prevent indefinitely looping entries [\#516](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/516) ([mhenrixon](https://github.com/mhenrixon))
54
+
55
+ **Closed issues:**
56
+
57
+ - Missing web interface [\#514](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/514)
58
+
59
+ ## [v7.0.0.beta20](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta20) (2020-06-02)
60
+
61
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta19...v7.0.0.beta20)
6
62
 
7
63
  **Fixed bugs:**
8
64
 
9
65
  - Reaper can't be registered again if sidekiq gets killed by SIGKILL [\#490](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/490)
10
66
 
67
+ **Closed issues:**
68
+
69
+ - How do I turn this on for only one job class? [\#510](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/510)
70
+
11
71
  ## [v7.0.0.beta19](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta19) (2020-05-21)
12
72
 
13
73
  [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta18...v7.0.0.beta19)
@@ -379,7 +439,7 @@
379
439
  **Closed issues:**
380
440
 
381
441
  - Unique args in combination with sidekiq cron contains `\_aj\_symbol\_keys` [\#363](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/363)
382
- - Low quality peace of shit [\#360](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/360)
442
+ - Low quality piece of shit [\#360](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/360)
383
443
  - Passthrough has been deprecated and will be removed in redis-namespace 2.0 [\#338](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/338)
384
444
 
385
445
  ## [v6.0.12](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v6.0.12) (2019-02-28)
@@ -602,7 +662,6 @@
602
662
 
603
663
  **Merged pull requests:**
604
664
 
605
- - Add more details about testing uniqueness [\#301](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/301) ([mhenrixon](https://github.com/mhenrixon))
606
665
  - Update README.md [\#300](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/300) ([pirj](https://github.com/pirj))
607
666
 
608
667
  ## [v6.0.0.rc7](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v6.0.0.rc7) (2018-07-23)
@@ -622,6 +681,7 @@
622
681
 
623
682
  **Merged pull requests:**
624
683
 
684
+ - Add more details about testing uniqueness [\#301](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/301) ([mhenrixon](https://github.com/mhenrixon))
625
685
  - Adds changelog entry [\#299](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/299) ([mhenrixon](https://github.com/mhenrixon))
626
686
  - Fix README [\#298](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/298) ([mhenrixon](https://github.com/mhenrixon))
627
687
 
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,9 +10,11 @@ module SidekiqUniqueJobs
10
10
  #
11
11
  class Cli < Thor
12
12
  # :nodoc:
13
- def self.banner(command, _namespace = nil, _subcommand = false)
13
+ # rubocop:disable Style/OptionalBooleanParameter
14
+ def self.banner(command, _namespace = nil, _subcommand = false) # rubocop:disable Style/OptionalBooleanParameter
14
15
  "jobs #{@package_name} #{command.usage}" # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
15
16
  end
17
+ # rubocop:enable Style/OptionalBooleanParameter
16
18
 
17
19
  desc "list PATTERN", "list all unique digests and their expiry time"
18
20
  option :count, aliases: :c, type: :numeric, default: 1000, desc: "The max number of digests to return"
@@ -7,6 +7,7 @@
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"
@@ -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]
@@ -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
@@ -97,7 +97,7 @@ module SidekiqUniqueJobs
97
97
  end
98
98
 
99
99
  # The method to use for filtering unique arguments
100
- def lock_args_method
100
+ def lock_args_method # rubocop:disable Metrics/CyclomaticComplexity
101
101
  @lock_args_method ||= worker_options[LOCK_ARGS] || worker_options[UNIQUE_ARGS]
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)
@@ -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]
@@ -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
@@ -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
@@ -25,11 +25,19 @@ module SidekiqUniqueJobs
25
25
  def self.configure_server # rubocop:disable Metrics/MethodLength
26
26
  Sidekiq.configure_server do |config|
27
27
  config.client_middleware do |chain|
28
- chain.add SidekiqUniqueJobs::Middleware::Client
28
+ if defined?(Apartment::Sidekiq::Middleware::Client)
29
+ chain.insert_after Apartment::Sidekiq::Middleware::Client, SidekiqUniqueJobs::Middleware::Client
30
+ else
31
+ chain.add SidekiqUniqueJobs::Middleware::Client
32
+ end
29
33
  end
30
34
 
31
35
  config.server_middleware do |chain|
32
- chain.add SidekiqUniqueJobs::Middleware::Server
36
+ if defined?(Apartment::Sidekiq::Middleware::Server)
37
+ chain.insert_after Apartment::Sidekiq::Middleware::Server, SidekiqUniqueJobs::Middleware::Server
38
+ else
39
+ chain.add SidekiqUniqueJobs::Middleware::Server
40
+ end
33
41
  end
34
42
 
35
43
  config.on(:startup) do
@@ -51,7 +59,11 @@ module SidekiqUniqueJobs
51
59
  def self.configure_client
52
60
  Sidekiq.configure_client do |config|
53
61
  config.client_middleware do |chain|
54
- chain.add SidekiqUniqueJobs::Middleware::Client
62
+ if defined?(Apartment::Sidekiq::Middleware::Client)
63
+ chain.insert_after Apartment::Sidekiq::Middleware::Client, SidekiqUniqueJobs::Middleware::Client
64
+ else
65
+ chain.add SidekiqUniqueJobs::Middleware::Client
66
+ end
55
67
  end
56
68
  end
57
69
  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,26 @@ 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")
129
+ end
130
+
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
127
136
  end
128
137
  end
129
138
 
130
- result.flatten.compact.any? { |job| load_json(job)[LOCK_DIGEST] == digest }
139
+ false
131
140
  end
132
141
  end
133
142
 
@@ -144,7 +153,7 @@ module SidekiqUniqueJobs
144
153
  conn.sscan_each("queues", &block)
145
154
  end
146
155
 
147
- def entries(conn, queue) # rubocop:disable Metrics/MethodLength
156
+ def entries(conn, queue, &block) # rubocop:disable Metrics/MethodLength
148
157
  queue_key = "queue:#{queue}"
149
158
  initial_size = conn.llen(queue_key)
150
159
  deleted_size = 0
@@ -157,9 +166,9 @@ module SidekiqUniqueJobs
157
166
  entries = conn.lrange(queue_key, range_start, range_end)
158
167
  page += 1
159
168
 
160
- entries.each do |entry|
161
- yield entry
162
- end
169
+ break if entries.empty?
170
+
171
+ entries.each(&block)
163
172
 
164
173
  deleted_size = initial_size - conn.llen(queue_key)
165
174
  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.beta20"
6
+ VERSION = "7.0.0.beta25"
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.beta20
4
+ version: 7.0.0.beta25
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-06-02 00:00:00.000000000 Z
11
+ date: 2020-10-26 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.1.2
395
- signing_key:
242
+ rubygems_version: 3.0.3
243
+ signing_key:
396
244
  specification_version: 4
397
245
  summary: Sidekiq middleware that prevents duplicates jobs
398
246
  test_files: []