module Resque::Append

Constants

VERSION

Public Class Methods

disable!() click to toggle source
# File lib/resque/append.rb, line 5
def self.disable!
  self.enabled = false
end
enable!() click to toggle source
# File lib/resque/append.rb, line 9
def self.enable!
  self.enabled = true
end
enabled() click to toggle source
# File lib/resque/append.rb, line 17
def self.enabled
  @enabled
end
enabled=(enabled) click to toggle source
# File lib/resque/append.rb, line 25
def self.enabled=(enabled)
  @enabled = !!enabled
  Resque::Append.work if @enabled
  @enabled
end
enabled?() click to toggle source
# File lib/resque/append.rb, line 21
def self.enabled?
  !!@enabled
end
idle!() click to toggle source
# File lib/resque/append.rb, line 31
def self.idle!
  @processing = false
end
processing!() click to toggle source
# File lib/resque/append.rb, line 35
def self.processing!
  @processing = true
end
processing=(processing) click to toggle source
# File lib/resque/append.rb, line 39
def self.processing=(processing)
  @processing = !!processing
end
processing?() click to toggle source
# File lib/resque/append.rb, line 43
def self.processing?
  !!@processing
end
reset!() click to toggle source
# File lib/resque/append.rb, line 13
def self.reset!
  Resque.queues.each { |q| Resque.remove_queue(q) }
end
work() click to toggle source
# File lib/resque/append.rb, line 58
def self.work
  if Resque::Append.enabled? && !Resque::Append.processing?
    Resque::Append.processing!
    Resque::Append.worker.work(0)
    Resque::Append.idle!
  end
end
worker() click to toggle source
# File lib/resque/append.rb, line 51
def self.worker
  @worker ||= Resque::Worker.new("*").tap do |w|
    w.cant_fork  = true
    w.term_child = true
  end
end
worker=(worker) click to toggle source
# File lib/resque/append.rb, line 47
def self.worker=(worker)
  @worker = worker
end

Public Instance Methods

after_enqueue_append(*args) click to toggle source
# File lib/resque/append.rb, line 66
def after_enqueue_append(*args)
  Resque::Append.work
end
after_schedule_append(*args) click to toggle source

resque-scheduler integration

# File lib/resque/append.rb, line 71
def after_schedule_append(*args)
  if Resque::Append.enabled?
    # delayed runs last, popped alphabetically when worker is *
    Resque.enqueue_to("zzzzzzed", self, *args)
  end
end