class Backburner::AllqWatcher

Attributes

tube[RW]

Public Class Methods

new(tube, allq_wrapper) click to toggle source
# File lib/backburner/allq_wrapper.rb, line 9
def initialize(tube, allq_wrapper)
  @tube = tube
  @allq_wrapper = allq_wrapper
end

Public Instance Methods

watch() click to toggle source
# File lib/backburner/allq_wrapper.rb, line 14
def watch
  Thread.new do
    loop do
      ran = false
      job = @allq_wrapper.get(@tube_name)
      if job.body
        perform(job)
        ran = true
      end
      # Wait if nothing returned
      sleep(rand * 3) unless ran
    end
  end
end