Class: Rails::Queue::Queue
- Inherits:
-
Queue
- Object
- Queue
- Rails::Queue::Queue
- Defined in:
- lib/rails/queue/queue.rb
Overview
A Queue that simply inherits from STDLIB’s Queue. When this queue is used, Rails automatically starts a job runner in a background thread.
Direct Known Subclasses
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#drain ⇒ Object
Drain the queue, running all jobs in a different thread.
-
#initialize(consumer_options = {}) ⇒ Queue
constructor
A new instance of Queue.
Constructor Details
#initialize(consumer_options = {}) ⇒ Queue
Returns a new instance of Queue.
14 15 16 17 |
# File 'lib/rails/queue/queue.rb', line 14 def initialize( = {}) super() @consumer_options = end |
Instance Attribute Details
#consumer ⇒ Object
19 20 21 |
# File 'lib/rails/queue/queue.rb', line 19 def consumer @consumer ||= ThreadedQueueConsumer.new(self, @consumer_options) end |
Instance Method Details
#drain ⇒ Object
Drain the queue, running all jobs in a different thread. This method may not be available on production queues.
25 26 27 28 29 |
# File 'lib/rails/queue/queue.rb', line 25 def drain # run the jobs in a separate thread so assumptions of synchronous # jobs are caught in test mode. consumer.drain end |