module Sidekiq::LimitFetch

Constants

TIMEOUT

Public Instance Methods

bulk_requeue(*args) click to toggle source
# File lib/sidekiq/limit_fetch.rb, line 29
def bulk_requeue(*args)
  Sidekiq::BasicFetch.bulk_requeue(*args)
end
new(_) click to toggle source
# File lib/sidekiq/limit_fetch.rb, line 19
def new(_)
  self
end
redis_retryable() { || ... } click to toggle source
# File lib/sidekiq/limit_fetch.rb, line 33
def redis_retryable
  yield
rescue Redis::BaseConnectionError
  sleep 1
  retry
end
retrieve_work() click to toggle source
# File lib/sidekiq/limit_fetch.rb, line 23
def retrieve_work
  queue, job = redis_brpop(Queues.acquire)
  Queues.release_except(queue)
  UnitOfWork.new(queue, job) if job
end

Private Instance Methods

redis_brpop(queues) click to toggle source
# File lib/sidekiq/limit_fetch.rb, line 44
def redis_brpop(queues)
  if queues.empty?
    sleep TIMEOUT  # there are no queues to handle, so lets sleep
    []             # and return nothing
  else
    redis_retryable { Sidekiq.redis { |it| it.brpop *queues, TIMEOUT } }
  end
end