module PikaQue::Worker::ClassMethods
Attributes
handler_class[R]
handler_opts[R]
local_config[R]
priority[R]
queue_name[R]
queue_opts[R]
Public Instance Methods
config(opts)
click to toggle source
# File lib/pika_que/worker.rb, line 86 def config(opts) @local_config = opts end
enqueue(msg, opts={})
click to toggle source
# File lib/pika_que/worker.rb, line 68 def enqueue(msg, opts={}) opts[:routing_key] ||= (queue_opts[:routing_key] if queue_opts) opts[:to_queue] ||= queue_name opts[:priority] ||= priority publisher.publish(msg, opts) end
Also aliased as: perform_async, perform_at
enqueue_at(msg, timestamp, opts={})
click to toggle source
# File lib/pika_que/worker.rb, line 77 def enqueue_at(msg, timestamp, opts={}) opts[:to_queue] ||= "#{publisher.exchange_name}-delay" work_queue = opts.delete(:routing_key) || (queue_opts[:routing_key] if queue_opts) || queue_name opts[:headers] = { work_at: timestamp, work_queue: work_queue } publisher.publish(msg, opts) end
from_queue(q, opts={})
click to toggle source
# File lib/pika_que/worker.rb, line 57 def from_queue(q, opts={}) @queue_name = q.to_s @priority = opts.delete(:priority) @queue_opts = opts end
handle_with(handler, opts={})
click to toggle source
# File lib/pika_que/worker.rb, line 63 def handle_with(handler, opts={}) @handler_class = handler @handler_opts = opts end
Private Instance Methods
publisher()
click to toggle source
# File lib/pika_que/worker.rb, line 92 def publisher @publisher ||= PikaQue::Publisher.new(local_config || {}) end