Sha256: 4e88c533767796fc44f0217f8198e2dd3bb2aa9e8a6d32676bdda9a86431731d
Contents?: true
Size: 1.59 KB
Versions: 2
Compression:
Stored size: 1.59 KB
Contents
# frozen_string_literal: true require "sidekiq" require_relative "./throttled_retriever" module Sidekiq module Throttled module Patches module SuperFetch def self.prepended(base) base.prepend(ThrottledRetriever) end private # Calls SuperFetch UnitOfWork's requeue to remove the job from the # temporary queue and push job back to the head of the queue, so that # the job won't be tried immediately after it was requeued (in most cases). # # @note This is triggered when job is throttled. # # @return [void] def requeue_throttled(work) # SuperFetch UnitOfWork's requeue will remove it from the temporary # queue and then requeue it, so no acknowledgement call is needed. work.requeue end # Returns list of non-paused queues to try to fetch jobs from. # # @note It may return an empty array. # @return [Array<Array(String, String)>] def active_queues # Create a hash of throttled queues for fast lookup throttled_queues = Throttled.cooldown&.queues&.to_h { |queue| [queue, true] } return super if throttled_queues.nil? || throttled_queues.empty? # Reject throttled queues from the list of active queues super.reject { |queue, _private_queue| throttled_queues[queue] } end end end end end begin require "sidekiq/pro/super_fetch" Sidekiq::Pro::SuperFetch.prepend(Sidekiq::Throttled::Patches::SuperFetch) rescue LoadError # Sidekiq Pro is not available end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sidekiq-throttled-1.4.0 | lib/sidekiq/throttled/patches/super_fetch.rb |
sidekiq-throttled-1.3.0 | lib/sidekiq/throttled/patches/super_fetch.rb |