Module: PikaQue::Worker
- Included in:
- RailsWorker
- Defined in:
- lib/pika_que/worker.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #ack! ⇒ Object
- #consumer_arguments ⇒ Object
- #initialize(opts = {}) ⇒ Object
- #logger ⇒ Object
- #prepare ⇒ Object
- #reject! ⇒ Object
- #requeue! ⇒ Object
- #run ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #work(delivery_info, metadata, msg) ⇒ Object
Class Method Details
.included(base) ⇒ Object
45 46 47 |
# File 'lib/pika_que/worker.rb', line 45 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#ack! ⇒ Object
33 |
# File 'lib/pika_que/worker.rb', line 33 def ack!; :ack end |
#consumer_arguments ⇒ Object
41 42 43 |
# File 'lib/pika_que/worker.rb', line 41 def consumer_arguments self.class.priority.nil? ? {} : { :'x-priority' => self.class.priority } end |
#initialize(opts = {}) ⇒ Object
6 7 8 |
# File 'lib/pika_que/worker.rb', line 6 def initialize(opts = {}) @subscriber = PikaQue::Subscriber.new(opts.merge(self.class.local_config || {})) end |
#prepare ⇒ Object
10 11 12 13 |
# File 'lib/pika_que/worker.rb', line 10 def prepare @subscriber.setup_queue(self.class.queue_name, self.class.queue_opts) @subscriber.setup_handler(self.class.handler_class, self.class.handler_opts) end |
#reject! ⇒ Object
34 |
# File 'lib/pika_que/worker.rb', line 34 def reject!; :reject; end |
#requeue! ⇒ Object
35 |
# File 'lib/pika_que/worker.rb', line 35 def requeue!; :requeue; end |
#run ⇒ Object
15 16 17 |
# File 'lib/pika_que/worker.rb', line 15 def run @subscriber.subscribe(self) end |
#start ⇒ Object
19 20 21 22 |
# File 'lib/pika_que/worker.rb', line 19 def start prepare run end |
#stop ⇒ Object
24 25 26 27 |
# File 'lib/pika_que/worker.rb', line 24 def stop @subscriber.unsubscribe @subscriber.teardown end |
#work(delivery_info, metadata, msg) ⇒ Object
29 30 31 |
# File 'lib/pika_que/worker.rb', line 29 def work(delivery_info, , msg) perform(msg) end |