Module: PikaQue::Worker::ClassMethods
- Defined in:
- lib/pika_que/worker.rb
Instance Attribute Summary collapse
-
#handler_class ⇒ Object
readonly
Returns the value of attribute handler_class.
-
#handler_opts ⇒ Object
readonly
Returns the value of attribute handler_opts.
-
#local_config ⇒ Object
readonly
Returns the value of attribute local_config.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#queue_name ⇒ Object
readonly
Returns the value of attribute queue_name.
-
#queue_opts ⇒ Object
readonly
Returns the value of attribute queue_opts.
Instance Method Summary collapse
- #config(opts) ⇒ Object
- #enqueue(msg, opts = {}) ⇒ Object (also: #perform_async, #perform_at)
- #enqueue_at(msg, timestamp, opts = {}) ⇒ Object
- #from_queue(q, opts = {}) ⇒ Object
- #handle_with(handler, opts = {}) ⇒ Object
Instance Attribute Details
#handler_class ⇒ Object (readonly)
Returns the value of attribute handler_class.
52 53 54 |
# File 'lib/pika_que/worker.rb', line 52 def handler_class @handler_class end |
#handler_opts ⇒ Object (readonly)
Returns the value of attribute handler_opts.
53 54 55 |
# File 'lib/pika_que/worker.rb', line 53 def handler_opts @handler_opts end |
#local_config ⇒ Object (readonly)
Returns the value of attribute local_config.
55 56 57 |
# File 'lib/pika_que/worker.rb', line 55 def local_config @local_config end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
54 55 56 |
# File 'lib/pika_que/worker.rb', line 54 def priority @priority end |
#queue_name ⇒ Object (readonly)
Returns the value of attribute queue_name.
50 51 52 |
# File 'lib/pika_que/worker.rb', line 50 def queue_name @queue_name end |
#queue_opts ⇒ Object (readonly)
Returns the value of attribute queue_opts.
51 52 53 |
# File 'lib/pika_que/worker.rb', line 51 def queue_opts @queue_opts end |
Instance Method Details
#config(opts) ⇒ Object
86 87 88 |
# File 'lib/pika_que/worker.rb', line 86 def config(opts) @local_config = opts end |
#enqueue(msg, opts = {}) ⇒ Object Also known as: perform_async, perform_at
68 69 70 71 72 73 74 |
# 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 |
#enqueue_at(msg, timestamp, opts = {}) ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/pika_que/worker.rb', line 77 def enqueue_at(msg, , 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: , work_queue: work_queue } publisher.publish(msg, opts) end |
#from_queue(q, opts = {}) ⇒ Object
57 58 59 60 61 |
# 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 = {}) ⇒ Object
63 64 65 66 |
# File 'lib/pika_que/worker.rb', line 63 def handle_with(handler, opts={}) @handler_class = handler @handler_opts = opts end |