Sha256: 9b14586acf224c8b105ced1cdab06bf204bc27dead91b87a37f57324f28123c5
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true require "sidekiq" require "sidekiq/fetch" require_relative "./throttled_retriever" module Sidekiq module Throttled module Patches module BasicFetch def self.prepended(base) base.prepend(ThrottledRetriever) end private # Pushes job back to the head of the queue, so that job won't be tried # immediately after it was requeued (in most cases). # # @note This is triggered when job is throttled. So it is same operation # Sidekiq performs upon `Sidekiq::Worker.perform_async` call. # # @return [void] def requeue_throttled(work) redis { |conn| conn.lpush(work.queue, work.job) } end # Returns list of queues to try to fetch jobs from. # # @note It may return an empty array. # @param [Array<String>] queues # @return [Array<String>] def queues_cmd throttled_queues = Throttled.cooldown&.queues return super if throttled_queues.nil? || throttled_queues.empty? super - throttled_queues end end end end end Sidekiq::BasicFetch.prepend(Sidekiq::Throttled::Patches::BasicFetch)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sidekiq-throttled-1.4.0 | lib/sidekiq/throttled/patches/basic_fetch.rb |
sidekiq-throttled-1.3.0 | lib/sidekiq/throttled/patches/basic_fetch.rb |