sidekiq-unique-jobs 6.0.19 → 6.0.24

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: 5e7339c3de1638fdd81aa8d3b90d0d09a6a18caa35fc0452efb97464853b4d3f
4
- data.tar.gz: 40a8a95a053e13b2bee8fc34ecd7d684d24e9b109f00412bc0f72952d71c6386
3
+ metadata.gz: c8ea40e3f79410d8c203d4df254cb6b9b756123b6aacaf15843843c4bd4337c5
4
+ data.tar.gz: 353ea6c92b0d945ad6571e0c20039c9df7093b74404d05a6e9633447e58827f9
5
5
  SHA512:
6
- metadata.gz: 2c2c01161c61bf276964c68d637352769e31d02c10bcc7ae378731797c5729ef6f72c9dcfc0eaebc670143e3355703aa2869e13bda222a0251e2149e614d27c6
7
- data.tar.gz: ed733e7b12b9411ace00f2c5161e3c7c84ca039988dade9cff4900cdf01c45e42a99d565b4abcd76ce6302ba26e1818bf4fb954ec357f9d98229e4bb37098a48
6
+ metadata.gz: 9c8c527b0a495bcd33672bf02afafadfe0b737394e2e357ca9d40d011ab5e5aaf6c927ae9c67e0bb7b4d2ebbfd43b485fa10e2fec97e3d0523371c3e06f8f1c7
7
+ data.tar.gz: ba00d25b2f3c6dc5d40cb472de73417c83e4c9c75005cd3339d80e86bb00964f34d8a0ea485e50af2406db025889e901610bc382af00588f82297d0fb16c9d97
data/README.md CHANGED
@@ -344,11 +344,17 @@ If you need to perform any additional work after the lock has been released you
344
344
  **Exception 1:** UntilExecuting unlocks and calls back before yielding.
345
345
  **Exception 2:** UntilExpired expires eventually, no after_unlock hook is called.
346
346
 
347
+ **NOTE:** _It is also possible to write this code as a class method._
348
+
347
349
  ```ruby
348
350
  class UniqueJobWithFilterMethod
349
351
  include Sidekiq::Worker
350
352
  sidekiq_options lock: :while_executing,
351
353
 
354
+ def self.after_unlock
355
+ # block has yielded and lock is released
356
+ end
357
+
352
358
  def after_unlock
353
359
  # block has yielded and lock is released
354
360
  end
@@ -46,16 +46,21 @@ module SidekiqUniqueJobs
46
46
 
47
47
  no_commands do
48
48
  def console_class
49
- if RUBY_PLATFORM == "JAVA"
50
- require "irb"
51
- return IRB
52
- end
49
+ return irb if RUBY_PLATFORM == "JAVA"
53
50
 
51
+ pry
52
+ end
53
+
54
+ def irb
55
+ require "irb"
56
+ IRB
57
+ end
58
+
59
+ def pry
54
60
  require "pry"
55
61
  Pry
56
62
  rescue LoadError, NameError
57
- require "irb"
58
- IRB
63
+ irb
59
64
  end
60
65
  end
61
66
  end
@@ -11,8 +11,10 @@ module SidekiqUniqueJobs
11
11
  CLASS_KEY ||= "class"
12
12
  JAVA ||= "java"
13
13
  JID_KEY ||= "jid"
14
+ LOCK_DIGEST_KEY ||= "lock_digest"
14
15
  LOCK_EXPIRATION_KEY ||= "lock_expiration"
15
16
  LOCK_TIMEOUT_KEY ||= "lock_timeout"
17
+ LOCK_TTL_KEY ||= "lock_ttl"
16
18
  LOG_DUPLICATE_KEY ||= "log_duplicate_payload"
17
19
  QUEUE_KEY ||= "queue"
18
20
  UNIQUE_ACROSS_QUEUES_KEY ||= "unique_across_queues"
@@ -15,9 +15,9 @@ module SidekiqUniqueJobs
15
15
  # @param [Sidekiq::RedisConnection, ConnectionPool] redis_pool the redis connection
16
16
  def initialize(item, redis_pool = nil)
17
17
  # @concurrency = 1 # removed in a0cff5bc42edbe7190d6ede7e7f845074d2d7af6
18
- @ttl = item[LOCK_EXPIRATION_KEY]
18
+ @ttl = item[LOCK_EXPIRATION_KEY] || item[LOCK_TTL_KEY]
19
19
  @jid = item[JID_KEY]
20
- @unique_digest = item[UNIQUE_DIGEST_KEY]
20
+ @unique_digest = item[UNIQUE_DIGEST_KEY] || item[LOCK_DIGEST_KEY]
21
21
  @lock_type = item[LOCK_KEY] || item[UNIQUE_KEY]
22
22
  @lock_type &&= @lock_type.to_sym
23
23
  @redis_pool = redis_pool
@@ -57,7 +57,7 @@ module SidekiqUniqueJobs
57
57
 
58
58
  # @return [Symbol]
59
59
  def lock_type
60
- @lock_type ||= options[LOCK_KEY] || item[LOCK_KEY] || unique_type
60
+ @lock_type ||= item[LOCK_KEY] || options[LOCK_KEY] || unique_type
61
61
  end
62
62
 
63
63
  def unique_type
@@ -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
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "digest"
4
+ require "openssl"
4
5
  require "sidekiq_unique_jobs/normalizer"
5
6
 
6
7
  module SidekiqUniqueJobs
@@ -47,7 +48,7 @@ module SidekiqUniqueJobs
47
48
  # Creates a namespaced unique digest based on the {#digestable_hash} and the {#unique_prefix}
48
49
  # @return [String] a unique digest
49
50
  def create_digest
50
- digest = Digest::MD5.hexdigest(Sidekiq.dump_json(digestable_hash))
51
+ digest = OpenSSL::Digest::MD5.hexdigest(Sidekiq.dump_json(digestable_hash))
51
52
  "#{unique_prefix}:#{digest}"
52
53
  end
53
54
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SidekiqUniqueJobs
4
- VERSION = "6.0.19"
4
+ VERSION = "6.0.24"
5
5
  end
@@ -4,7 +4,7 @@ begin
4
4
  require "delegate"
5
5
  require "rack"
6
6
  require "sidekiq/web"
7
- rescue LoadError # rubocop:disable Lint/SuppressedException
7
+ rescue LoadError
8
8
  # client-only usage
9
9
  end
10
10
 
@@ -49,7 +49,8 @@ redis.call('RPUSH', available_key, job_id)
49
49
 
50
50
  -- The client should only set ttl for until_expired
51
51
  -- The server should set ttl for all other jobs
52
- if lock == "until_expired" and ttl then
52
+ -- redis.log(redis.LOG_WARNING, "lock: " .. lock .. ", ttl: " .. tostring(ttl))
53
+ if lock == "until_expired" and ttl and ttl > 0 then
53
54
  -- We can't keep the key here because it will otherwise never be deleted
54
55
  redis.call('SREM', unique_keys, unique_digest)
55
56
 
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: 6.0.19
4
+ version: 6.0.24
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-03-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: concurrent-ruby
@@ -54,16 +54,22 @@ dependencies:
54
54
  name: thor
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - "~>"
57
+ - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: '0'
59
+ version: '0.20'
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '2.0'
60
63
  type: :runtime
61
64
  prerelease: false
62
65
  version_requirements: !ruby/object:Gem::Requirement
63
66
  requirements:
64
- - - "~>"
67
+ - - ">="
65
68
  - !ruby/object:Gem::Version
66
- version: '0'
69
+ version: '0.20'
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '2.0'
67
73
  - !ruby/object:Gem::Dependency
68
74
  name: bundler
69
75
  requirement: !ruby/object:Gem::Requirement
@@ -296,7 +302,7 @@ metadata:
296
302
  documentation_uri: https://mhenrixon.github.io/sidekiq-unique-jobs
297
303
  source_code_uri: https://github.com/mhenrixon/sidekiq-unique-jobs
298
304
  changelog_uri: https://github.com/mhenrixon/sidekiq-unique-jobs/CHANGELOG.md
299
- post_install_message:
305
+ post_install_message:
300
306
  rdoc_options: []
301
307
  require_paths:
302
308
  - lib
@@ -311,8 +317,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
311
317
  - !ruby/object:Gem::Version
312
318
  version: '0'
313
319
  requirements: []
314
- rubygems_version: 3.1.2
315
- signing_key:
320
+ rubygems_version: 3.1.4
321
+ signing_key:
316
322
  specification_version: 4
317
323
  summary: Sidekiq middleware that prevents duplicates jobs
318
324
  test_files: []