sidekiq-unique-jobs 7.1.0 → 7.1.5

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
@@ -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,10 +79,10 @@ 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
- timeout && (timeout.zero? || timeout.positive?)
85
+ timeout.nil? || timeout.positive?
86
86
  end
87
87
 
88
88
  #
@@ -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
@@ -271,18 +274,21 @@ module SidekiqUniqueJobs
271
274
  # @return [String] a previously enqueued token (now taken off the queue)
272
275
  #
273
276
  def pop_queued(conn, wait = nil)
274
- if wait || config.wait_for_lock?
275
- brpoplpush(conn, wait)
276
- else
277
+ wait ||= config.timeout if config.wait_for_lock?
278
+
279
+ if wait.nil?
277
280
  rpoplpush(conn)
281
+ else
282
+ brpoplpush(conn, wait)
278
283
  end
279
284
  end
280
285
 
281
286
  #
282
287
  # @api private
283
288
  #
284
- def brpoplpush(conn, wait = nil)
285
- wait ||= config.timeout
289
+ def brpoplpush(conn, wait)
290
+ raise InvalidArgument, "wait must be an integer" unless wait.is_a?(Integer)
291
+
286
292
  # passing timeout 0 to brpoplpush causes it to block indefinitely
287
293
  conn.brpoplpush(key.queued, key.primed, timeout: wait)
288
294
  end
@@ -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.0"
6
+ VERSION = "7.1.5"
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.0
4
+ version: 7.1.5
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-29 00:00:00.000000000 Z
11
+ date: 2021-07-28 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.21
264
+ rubygems_version: 3.2.24
265
265
  signing_key:
266
266
  specification_version: 4
267
267
  summary: Sidekiq middleware that prevents duplicates jobs