Class: Sidekiq::Throttled::BasicFetch
- Inherits:
-
BasicFetch
- Object
- BasicFetch
- Sidekiq::Throttled::BasicFetch
- Defined in:
- lib/sidekiq/throttled/basic_fetch.rb
Overview
Throttled version of ‘Sidekiq::BasicFetch` fetcher strategy.
Defined Under Namespace
Classes: UnitOfWork
Constant Summary collapse
- TIMEOUT =
2
Instance Method Summary collapse
-
#initialize(options) ⇒ BasicFetch
constructor
A new instance of BasicFetch.
- #retrieve_work ⇒ Sidekiq::BasicFetch::UnitOfWork?
Constructor Details
#initialize(options) ⇒ BasicFetch
Returns a new instance of BasicFetch.
17 18 19 20 21 |
# File 'lib/sidekiq/throttled/basic_fetch.rb', line 17 def initialize() @strictly_ordered_queues = ([:strict] ? true : false) @queues = [:queues].map { |q| "queue:#{q}" } @queues.uniq! if @strictly_ordered_queues end |
Instance Method Details
#retrieve_work ⇒ Sidekiq::BasicFetch::UnitOfWork?
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/sidekiq/throttled/basic_fetch.rb', line 24 def retrieve_work work = brpop return unless work work = UnitOfWork.new(*work) return work unless Throttled.throttled? work.job queue = "queue:#{work.queue_name}" Sidekiq.redis { |conn| conn.lpush(queue, work.job) } nil end |