Read more

Resque: Work off queues manually

Tobias Kraze
July 24, 2011Software engineer at makandra GmbH

If you're writing a spec for an application using Resque Show archive.org snapshot , you may need to work off queues manually without having an external worker running.

Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

For this, you could use ResqueSpec Show archive.org snapshot which basically stubs away Resque completely.

If you don't want that, but more closely mimic what actually happens, use this instead:

module Resque

  def self.work_off(*queues)
    if queues.any? { |queue| peek(queue) }
      worker = Worker.new(*queues)
      worker.cant_fork = true
      worker.work do
        unless queues.any? { |queue| peek(queue) }
          worker.shutdown
        end
      end
    end
  end

end
Posted by Tobias Kraze to makandra dev (2011-07-24 21:37)