Class: Droid::WorkerQueue
Instance Attribute Summary collapse
-
#prefetch ⇒ Object
readonly
Returns the value of attribute prefetch.
Attributes inherited from BaseQueue
#ex, #mq, #opts, #q, #queue_name
Instance Method Summary collapse
-
#initialize(queue_name, opts = {}) ⇒ WorkerQueue
constructor
A new instance of WorkerQueue.
- #setup ⇒ Object
- #subscribe(amqp_opts = {}, opts = {}) ⇒ Object
Methods inherited from BaseQueue
#destroy, #log, #tag, #teardown, #temp?
Constructor Details
#initialize(queue_name, opts = {}) ⇒ WorkerQueue
Returns a new instance of WorkerQueue.
74 75 76 77 78 79 |
# File 'lib/droid/queue.rb', line 74 def initialize(queue_name, opts={}) @prefetch = opts.delete(:prefetch) || 1 opts[:auto_delete] = false super(queue_name, opts) end |
Instance Attribute Details
#prefetch ⇒ Object (readonly)
Returns the value of attribute prefetch.
72 73 74 |
# File 'lib/droid/queue.rb', line 72 def prefetch @prefetch end |
Instance Method Details
#setup ⇒ Object
81 82 83 84 |
# File 'lib/droid/queue.rb', line 81 def setup super @mq.prefetch(self.prefetch) end |
#subscribe(amqp_opts = {}, opts = {}) ⇒ Object
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/droid/queue.rb', line 86 def subscribe(amqp_opts={}, opts={}) amqp_opts[:ack] = true super(amqp_opts, opts) do |request| begin yield request if block_given? ensure request.ack unless amqp_opts[:auto_ack] == false end end end |