Class: Rails::Queue::Queue

Inherits:
Queue
  • Object
show all
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

SynchronousQueue, TestQueue

Instance Attribute Summary collapse

Instance Method Summary collapse

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(consumer_options = {})
  super()
  @consumer_options = consumer_options
end

Instance Attribute Details

#consumerObject



19
20
21
# File 'lib/rails/queue/queue.rb', line 19

def consumer
  @consumer ||= ThreadedQueueConsumer.new(self, @consumer_options)
end

Instance Method Details

#drainObject

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