lib/sidekiq/throttled/patches/basic_fetch.rb in sidekiq-throttled-1.0.0.alpha.1 vs lib/sidekiq/throttled/patches/basic_fetch.rb in sidekiq-throttled-1.0.0
- old
+ new
@@ -5,27 +5,24 @@
module Sidekiq
module Throttled
module Patches
module BasicFetch
- class << self
- def apply!
- Sidekiq::BasicFetch.prepend(self) unless Sidekiq::BasicFetch.include?(self)
- end
- end
-
# Retrieves job from redis.
#
# @return [Sidekiq::Throttled::UnitOfWork, nil]
def retrieve_work
work = super
if work && Throttled.throttled?(work.job)
+ Throttled.cooldown&.notify_throttled(work.queue)
requeue_throttled(work)
return nil
end
+ Throttled.cooldown&.notify_admitted(work.queue) if work
+
work
end
private
@@ -44,17 +41,13 @@
#
# @note It may return an empty array.
# @param [Array<String>] queues
# @return [Array<String>]
def queues_cmd
- queues = super
-
- # TODO: Refactor to be prepended as an integration mixin during configuration stage
- # Or via configurable queues reducer
- queues -= Sidekiq::Pauzer.paused_queues.map { |name| "queue:#{name}" } if defined?(Sidekiq::Pauzer)
-
- queues
+ super - (Throttled.cooldown&.queues || [])
end
end
end
end
end
+
+Sidekiq::BasicFetch.prepend(Sidekiq::Throttled::Patches::BasicFetch)