sidekiq-unique-jobs 7.1.1 → 7.1.6

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.

@@ -116,8 +116,8 @@ module SidekiqUniqueJobs
116
116
  REAPER_RESURRECTOR_INTERVAL = 3600
117
117
 
118
118
  #
119
- # @return [true] enable reaper resurrector
120
- REAPER_RESURRECTOR_ENABLED = true
119
+ # @return [false] enable reaper resurrector
120
+ REAPER_RESURRECTOR_ENABLED = false
121
121
 
122
122
  #
123
123
  # @return [false] while useful it also adds overhead so disable lock_info by default
@@ -109,6 +109,7 @@ module SidekiqUniqueJobs
109
109
  def lock_failed(origin: :client)
110
110
  reflect(:lock_failed, item)
111
111
  call_strategy(origin: origin)
112
+ nil
112
113
  end
113
114
 
114
115
  def call_strategy(origin:)
@@ -59,8 +59,8 @@ module SidekiqUniqueJobs
59
59
  def initialize(job_hash = {})
60
60
  @type = job_hash[LOCK]&.to_sym
61
61
  @worker = SidekiqUniqueJobs.safe_constantize(job_hash[CLASS])
62
- @limit = job_hash.fetch(LOCK_LIMIT, 1)
63
- @timeout = job_hash.fetch(LOCK_TIMEOUT, 0)
62
+ @limit = job_hash.fetch(LOCK_LIMIT, 1)&.to_i
63
+ @timeout = job_hash.fetch(LOCK_TIMEOUT, 0)&.to_i
64
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 }
@@ -79,7 +79,7 @@ module SidekiqUniqueJobs
79
79
  # Indicate if timeout was set
80
80
  #
81
81
  #
82
- # @return [true,fakse]
82
+ # @return [true,false]
83
83
  #
84
84
  def wait_for_lock?
85
85
  timeout.nil? || timeout.positive?
@@ -179,6 +179,9 @@ module SidekiqUniqueJobs
179
179
  #
180
180
  # Used to reduce some duplication from the two methods
181
181
  #
182
+ # @see lock
183
+ # @see execute
184
+ #
182
185
  # @param [Sidekiq::RedisConnection, ConnectionPool] conn the redis connection
183
186
  # @param [Method] primed_method reference to the method to use for getting a primed token
184
187
  #
@@ -238,7 +241,7 @@ module SidekiqUniqueJobs
238
241
  def primed_async(conn, wait = nil, &block)
239
242
  primed_jid = Concurrent::Promises
240
243
  .future(conn) { |red_con| pop_queued(red_con, wait) }
241
- .value(add_drift(wait || config.ttl))
244
+ .value(add_drift(wait || config.timeout))
242
245
 
243
246
  handle_primed(primed_jid, &block)
244
247
  end
@@ -68,24 +68,46 @@ module Sidekiq
68
68
  prepend UniqueExtension
69
69
  end
70
70
 
71
- # See Sidekiq::Api
72
- class Job
73
- #
74
- # Provides extensions for unlocking jobs that are removed and deleted
75
- #
76
- # @author Mikael Henriksson <mikael@mhenrixon.com>
77
- #
78
- module UniqueExtension
71
+ if Sidekiq.const_defined?("JobRecord")
72
+ # See Sidekiq::Api
73
+ class JobRecord
79
74
  #
80
- # Wraps the original method to ensure locks for the job are deleted
75
+ # Provides extensions for unlocking jobs that are removed and deleted
81
76
  #
82
- def delete
83
- SidekiqUniqueJobs::Unlockable.delete!(item)
84
- super
77
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
78
+ #
79
+ module UniqueExtension
80
+ #
81
+ # Wraps the original method to ensure locks for the job are deleted
82
+ #
83
+ def delete
84
+ SidekiqUniqueJobs::Unlockable.delete!(item)
85
+ super
86
+ end
85
87
  end
88
+
89
+ prepend UniqueExtension
86
90
  end
91
+ else
92
+ # See Sidekiq::Api
93
+ class Job
94
+ #
95
+ # Provides extensions for unlocking jobs that are removed and deleted
96
+ #
97
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
98
+ #
99
+ module UniqueExtension
100
+ #
101
+ # Wraps the original method to ensure locks for the job are deleted
102
+ #
103
+ def delete
104
+ SidekiqUniqueJobs::Unlockable.delete!(item)
105
+ super
106
+ end
107
+ end
87
108
 
88
- prepend UniqueExtension
109
+ prepend UniqueExtension
110
+ end
89
111
  end
90
112
 
91
113
  # See Sidekiq::Api
@@ -51,7 +51,7 @@ module SidekiqUniqueJobs
51
51
  if Process.const_defined?("CLOCK_MONOTONIC")
52
52
  Process.clock_gettime(Process::CLOCK_MONOTONIC)
53
53
  else
54
- Time.now.to_f
54
+ now_f
55
55
  end
56
56
  end
57
57
  end
@@ -3,5 +3,5 @@
3
3
  module SidekiqUniqueJobs
4
4
  #
5
5
  # @return [String] the current SidekiqUniqueJobs version
6
- VERSION = "7.1.1"
6
+ VERSION = "7.1.6"
7
7
  end
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.1.1
4
+ version: 7.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-30 00:00:00.000000000 Z
11
+ date: 2021-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: brpoplpush-redis_script
@@ -261,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
261
261
  - !ruby/object:Gem::Version
262
262
  version: '0'
263
263
  requirements: []
264
- rubygems_version: 3.2.6
264
+ rubygems_version: 3.2.27
265
265
  signing_key:
266
266
  specification_version: 4
267
267
  summary: Sidekiq middleware that prevents duplicates jobs