Class: ActiveJob::QueueAdapters::QueueClassicAdapter
- Inherits:
-
Object
- Object
- ActiveJob::QueueAdapters::QueueClassicAdapter
- Defined in:
- lib/active_job/queue_adapters/queue_classic_adapter.rb
Defined Under Namespace
Classes: JobWrapper
Class Method Summary collapse
-
.build_queue(queue_name) ⇒ Object
Builds a
QC::Queue
object to schedule jobs on. - .enqueue(job) ⇒ Object
- .enqueue_at(job, timestamp) ⇒ Object
Class Method Details
.build_queue(queue_name) ⇒ Object
Builds a QC::Queue
object to schedule jobs on.
If you have a custom QC::Queue
subclass you’ll need to suclass ActiveJob::QueueAdapters::QueueClassicAdapter
and override the build_queue
method.
26 27 28 |
# File 'lib/active_job/queue_adapters/queue_classic_adapter.rb', line 26 def build_queue(queue_name) QC::Queue.new(queue_name) end |
.enqueue(job) ⇒ Object
7 8 9 |
# File 'lib/active_job/queue_adapters/queue_classic_adapter.rb', line 7 def enqueue(job) build_queue(job.queue_name).enqueue("#{JobWrapper.name}.perform", job.serialize) end |
.enqueue_at(job, timestamp) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/active_job/queue_adapters/queue_classic_adapter.rb', line 11 def enqueue_at(job, ) queue = build_queue(job.queue_name) unless queue.respond_to?(:enqueue_at) raise NotImplementedError, 'To be able to schedule jobs with Queue Classic ' \ 'the QC::Queue needs to respond to `enqueue_at(timestamp, method, *args)`. ' 'You can implement this yourself or you can use the queue_classic-later gem.' end queue.enqueue_at(, "#{JobWrapper.name}.perform", job.serialize) end |