sidekiq 6.5.0 → 6.5.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sidekiq might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dedc78179d612e64435e57f0f6644c2645c06ffdc24151c9ad51df4035b51efa
4
- data.tar.gz: 5987eba09190793cfccbff56066b54b5308a1fe74be7551cb5b9d6d03d256c3a
3
+ metadata.gz: 1afbc6a1a0b14403e9148e746c08e0a2b24e634fca05288982c96719675607de
4
+ data.tar.gz: 3ff3f8df76b565f42030462eb8d09b673b89751dcd6a0b7c41a255789960d321
5
5
  SHA512:
6
- metadata.gz: 9a26b5eb6e2248870f07ede054cac8330b52ad548d27b40d3950b6d985ef5ef8359e4dfc062757dc4b479036f0b2716bacfc821a20bd63413ea7c3f772bc6ead
7
- data.tar.gz: 46a35f7f27693364b1b6077e602d3f69e476508654157f48fcd457a70bbcdb563f8515812ef37abae207604596e1d42f78132ac54471109f913e87c11a707cdb
6
+ metadata.gz: e8a68611735322d98cc517f1d03ef02394497f8eb505e0db496909cac1f6b7f0179f38ce1966546f717115395102c78fdad9ae0fd947360307b9288dcc22b369
7
+ data.tar.gz: 163e41dfb153a4e2ec50d407bde08cb8a395909807053f24478a73af1a6a9858b5aec92cbf618d4d066560a2b7bedaa2f88b48f823609e2d78f21320270cb97e
data/Changes.md CHANGED
@@ -2,12 +2,16 @@
2
2
 
3
3
  [Sidekiq Changes](https://github.com/mperham/sidekiq/blob/main/Changes.md) | [Sidekiq Pro Changes](https://github.com/mperham/sidekiq/blob/main/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/mperham/sidekiq/blob/main/Ent-Changes.md)
4
4
 
5
+ 6.5.1
6
+ ----------
7
+
8
+ - Fix `push_bulk` breakage [#5387]
9
+
5
10
  6.5.0
6
11
  ---------
7
12
 
8
13
  - Substantial refactoring of Sidekiq server internals, part of a larger effort
9
- to reduce Sidekiq's internal usage of global methods and data, see [docs/component.md](docs/component.md),
10
- [docs/global_to_local.md](docs/global_to_local.md) and [docs/middleware.md](docs/middleware.md).
14
+ to reduce Sidekiq's internal usage of global methods and data, see [docs/global_to_local.md](docs/global_to_local.md) and [docs/middleware.md](docs/middleware.md).
11
15
  - **Add beta support for the `redis-client` gem**. This will become the default Redis driver in Sidekiq 7.0. [#5298]
12
16
  Read more: https://github.com/mperham/sidekiq/wiki/Using-redis-client
13
17
  - **Add beta support for DB transaction-aware client** [#5291]
Binary file
data/lib/sidekiq/api.rb CHANGED
@@ -217,24 +217,30 @@ module Sidekiq
217
217
  include Enumerable
218
218
 
219
219
  ##
220
- # Return all known queues within Redis.
220
+ # Fetch all known queues within Redis.
221
221
  #
222
+ # @return [Array<Sidekiq::Queue>]
222
223
  def self.all
223
224
  Sidekiq.redis { |c| c.sscan_each("queues").to_a }.sort.map { |q| Sidekiq::Queue.new(q) }
224
225
  end
225
226
 
226
227
  attr_reader :name
227
228
 
229
+ # @param name [String] the name of the queue
228
230
  def initialize(name = "default")
229
231
  @name = name.to_s
230
232
  @rname = "queue:#{name}"
231
233
  end
232
234
 
235
+ # The current size of the queue within Redis.
236
+ # This value is real-time and can change between calls.
237
+ #
238
+ # @return [Integer] the size
233
239
  def size
234
240
  Sidekiq.redis { |con| con.llen(@rname) }
235
241
  end
236
242
 
237
- # Sidekiq Pro overrides this
243
+ # @return [Boolean] if the queue is currently paused
238
244
  def paused?
239
245
  false
240
246
  end
@@ -243,7 +249,7 @@ module Sidekiq
243
249
  # Calculates this queue's latency, the difference in seconds since the oldest
244
250
  # job in the queue was enqueued.
245
251
  #
246
- # @return Float
252
+ # @return [Float] in seconds
247
253
  def latency
248
254
  entry = Sidekiq.redis { |conn|
249
255
  conn.lrange(@rname, -1, -1)
@@ -279,12 +285,17 @@ module Sidekiq
279
285
  ##
280
286
  # Find the job with the given JID within this queue.
281
287
  #
282
- # This is a slow, inefficient operation. Do not use under
288
+ # This is a *slow, inefficient* operation. Do not use under
283
289
  # normal conditions.
290
+ #
291
+ # @param jid [String] the job_id to look for
292
+ # @return [Sidekiq::JobRecord]
293
+ # @return [nil] if not found
284
294
  def find_job(jid)
285
295
  detect { |j| j.jid == jid }
286
296
  end
287
297
 
298
+ # delete all jobs within this queue
288
299
  def clear
289
300
  Sidekiq.redis do |conn|
290
301
  conn.multi do |transaction|
@@ -310,15 +321,16 @@ module Sidekiq
310
321
  class JobRecord
311
322
  attr_reader :item
312
323
  attr_reader :value
324
+ attr_reader :queue
313
325
 
314
- def initialize(item, queue_name = nil)
326
+ def initialize(item, queue_name = nil) # :nodoc:
315
327
  @args = nil
316
328
  @value = item
317
329
  @item = item.is_a?(Hash) ? item : parse(item)
318
330
  @queue = queue_name || @item["queue"]
319
331
  end
320
332
 
321
- def parse(item)
333
+ def parse(item) # :nodoc:
322
334
  Sidekiq.load_json(item)
323
335
  rescue JSON::ParserError
324
336
  # If the job payload in Redis is invalid JSON, we'll load
@@ -416,15 +428,12 @@ module Sidekiq
416
428
  end
417
429
  end
418
430
 
419
- attr_reader :queue
420
-
421
431
  def latency
422
432
  now = Time.now.to_f
423
433
  now - (@item["enqueued_at"] || @item["created_at"] || now)
424
434
  end
425
435
 
426
- ##
427
- # Remove this job from the queue.
436
+ # Remove this job from the queue
428
437
  def delete
429
438
  count = Sidekiq.redis { |conn|
430
439
  conn.lrem("queue:#{@queue}", 1, @value)
@@ -432,6 +441,7 @@ module Sidekiq
432
441
  count != 0
433
442
  end
434
443
 
444
+ # Access arbitrary attributes within the job hash
435
445
  def [](name)
436
446
  # nil will happen if the JSON fails to parse.
437
447
  # We don't guarantee Sidekiq will work with bad job JSON but we should
@@ -469,11 +479,13 @@ module Sidekiq
469
479
  end
470
480
  end
471
481
 
482
+ # Represents a job within a Redis sorted set where the score
483
+ # represents a timestamp for the job.
472
484
  class SortedEntry < JobRecord
473
485
  attr_reader :score
474
486
  attr_reader :parent
475
487
 
476
- def initialize(parent, score, item)
488
+ def initialize(parent, score, item) # :nodoc:
477
489
  super(item)
478
490
  @score = Float(score)
479
491
  @parent = parent
@@ -491,12 +503,17 @@ module Sidekiq
491
503
  end
492
504
  end
493
505
 
506
+ # Change the scheduled time for this job.
507
+ #
508
+ # @param [Time] the new timestamp when this job will be enqueued.
494
509
  def reschedule(at)
495
510
  Sidekiq.redis do |conn|
496
511
  conn.zincrby(@parent.name, at.to_f - @score, Sidekiq.dump_json(@item))
497
512
  end
498
513
  end
499
514
 
515
+ # Enqueue this job from the scheduled or dead set so it will
516
+ # be executed at some point in the near future.
500
517
  def add_to_queue
501
518
  remove_job do |message|
502
519
  msg = Sidekiq.load_json(message)
@@ -504,6 +521,8 @@ module Sidekiq
504
521
  end
505
522
  end
506
523
 
524
+ # enqueue this job from the retry set so it will be executed
525
+ # at some point in the near future.
507
526
  def retry
508
527
  remove_job do |message|
509
528
  msg = Sidekiq.load_json(message)
@@ -512,8 +531,7 @@ module Sidekiq
512
531
  end
513
532
  end
514
533
 
515
- ##
516
- # Place job in the dead set
534
+ # Move this job from its current set into the Dead set.
517
535
  def kill
518
536
  remove_job do |message|
519
537
  DeadSet.new.kill(message)
data/lib/sidekiq/cli.rb CHANGED
@@ -12,7 +12,7 @@ require "sidekiq"
12
12
  require "sidekiq/component"
13
13
  require "sidekiq/launcher"
14
14
 
15
- module Sidekiq
15
+ module Sidekiq # :nodoc:
16
16
  class CLI
17
17
  include Sidekiq::Component
18
18
  include Singleton unless $TESTING
@@ -220,7 +220,7 @@ module Sidekiq
220
220
 
221
221
  def atomic_push(conn, payloads)
222
222
  if payloads.first.key?("at")
223
- conn.zadd("schedule", *payloads.map { |hash|
223
+ conn.zadd("schedule", payloads.flat_map { |hash|
224
224
  at = hash.delete("at").to_s
225
225
  [at, Sidekiq.dump_json(hash)]
226
226
  })
@@ -1,7 +1,7 @@
1
1
  module Sidekiq
2
2
  ##
3
3
  # Sidekiq::Component assumes a config instance is available at @config
4
- module Component
4
+ module Component # :nodoc:
5
5
  attr_reader :config
6
6
 
7
7
  def watchdog(last_words)
data/lib/sidekiq/delay.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Sidekiq
3
+ module Sidekiq # :nodoc:
4
4
  module Extensions
5
5
  def self.enable_delay!
6
6
  warn "Sidekiq's Delayed Extensions will be removed in Sidekiq 7.0", uplevel: 1
data/lib/sidekiq/fetch.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require "sidekiq"
4
4
  require "sidekiq/component"
5
5
 
6
- module Sidekiq
6
+ module Sidekiq # :nodoc:
7
7
  class BasicFetch
8
8
  include Sidekiq::Component
9
9
  # We want the fetch operation to timeout every few seconds so the thread
@@ -176,7 +176,7 @@ module Sidekiq
176
176
  # logger.debug { "Failure! Retry #{count} in #{delay} seconds" }
177
177
  retry_at = Time.now.to_f + delay
178
178
  payload = Sidekiq.dump_json(msg)
179
- Sidekiq.redis do |conn|
179
+ redis do |conn|
180
180
  conn.zadd("retry", retry_at.to_s, payload)
181
181
  end
182
182
  else
@@ -195,7 +195,7 @@ module Sidekiq
195
195
 
196
196
  send_to_morgue(msg) unless msg["dead"] == false
197
197
 
198
- Sidekiq.death_handlers.each do |handler|
198
+ config.death_handlers.each do |handler|
199
199
  handler.call(msg, exception)
200
200
  rescue => e
201
201
  handle_exception(e, {context: "Error calling death handler", job: msg})
@@ -1,4 +1,6 @@
1
1
  module Sidekiq
2
+ # Server-side middleware must import this Module in order
3
+ # to get access to server resources during `call`.
2
4
  module ServerMiddleware
3
5
  attr_accessor :config
4
6
  def redis_pool
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sidekiq
4
- VERSION = "6.5.0"
4
+ VERSION = "6.5.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.5.0
4
+ version: 6.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Perham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-07 00:00:00.000000000 Z
11
+ date: 2022-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -72,6 +72,7 @@ files:
72
72
  - lib/generators/sidekiq/templates/job_spec.rb.erb
73
73
  - lib/generators/sidekiq/templates/job_test.rb.erb
74
74
  - lib/sidekiq.rb
75
+ - lib/sidekiq/.DS_Store
75
76
  - lib/sidekiq/api.rb
76
77
  - lib/sidekiq/cli.rb
77
78
  - lib/sidekiq/client.rb