class Tower::Queue

Public Class Methods

add(service,*args) click to toggle source
Current Queue Actions

never interact directly with instance call following proxy methods instead

# File lib/tower/queue.rb, line 13
def self.add(service,*args)
  current.send :add, service, *args
end
current() click to toggle source

Current Queue

# File lib/tower/queue.rb, line 5
def self.current
  @@current ||= new
end
new() click to toggle source
Initialize

adds methods from backend_instance_methods to instance extended here to avoid calling find_backend when class is loaded

# File lib/tower/queue.rb, line 22
def initialize
  extend backend_instance_methods
end

Private Instance Methods

add(service,*args) click to toggle source
Add

should be overriden in backend module see Tower::Queue:WithDelayedJob for example

# File lib/tower/queue.rb, line 49
def add(service,*args)
  raise NotImplementedError, "#add method not defined in #{backend_instance_methods}"
end
backend() click to toggle source
# File lib/tower/queue.rb, line 36
def backend
  @backend ||= find_backend
end
backend_instance_methods() click to toggle source
Backend

returns module for current backend, e.g. Tower::Queue::WithDelayedJob

# File lib/tower/queue.rb, line 28
def backend_instance_methods
  ext = case backend.to_s
    when 'Delayed::Backend::ActiveRecord::Job' then 'WithDelayedJob'
  end
  require_relative "queue/#{ext.underscore}"
  "Tower::Queue::#{ext}".constantize
end
find_backend() click to toggle source

returns current backend class, e.g. Delayed::Job

# File lib/tower/queue.rb, line 41
def find_backend
  return Delayed::Job if defined?(Delayed::Job)
  raise LoadError, "Tower::Queue requires delayed_job or resque gem"
end