Sha256: beb4ae9f0bdd7a0bcffb076a421950cbb2213e999c2d0edc113c82a5f61bb5cf

Contents?: true

Size: 904 Bytes

Versions: 2

Compression:

Stored size: 904 Bytes

Contents

require 'forwardable'
require 'sidekiq'
require 'sidekiq/manager'
require 'sidekiq/api'

module Sidekiq::LimitFetch
  autoload :UnitOfWork, 'sidekiq/limit_fetch/unit_of_work'

  require_relative 'limit_fetch/instances'
  require_relative 'limit_fetch/queues'
  require_relative 'limit_fetch/global/semaphore'
  require_relative 'limit_fetch/global/selector'
  require_relative 'limit_fetch/global/monitor'
  require_relative 'extensions/queue'
  require_relative 'extensions/manager'

  extend self

  def new(_)
    self
  end

  def retrieve_work
    queue, message = redis_brpop *Queues.acquire, Sidekiq::BasicFetch::TIMEOUT
    Queues.release_except queue
    UnitOfWork.new queue, message if message
  end

  def bulk_requeue(*args)
    Sidekiq::BasicFetch.bulk_requeue(*args)
  end

  private

  def redis_brpop(*args)
    return if args.size < 2
    Sidekiq.redis {|it| it.brpop *args }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sidekiq-limit_fetch-3.0.1 lib/sidekiq/limit_fetch.rb
sidekiq-limit_fetch-3.0.0 lib/sidekiq/limit_fetch.rb