mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
ActiveJob: Implemented enqueue_at for QueueClassic
This commit is contained in:
parent
368001c021
commit
5255e4f39f
3 changed files with 46 additions and 14 deletions
|
@ -5,11 +5,26 @@ module ActiveJob
|
|||
class QueueClassicAdapter
|
||||
class << self
|
||||
def enqueue(job, *args)
|
||||
QC::Queue.new(job.queue_name).enqueue("#{JobWrapper.name}.perform", job.name, *args)
|
||||
build_queue(job.queue_name).enqueue("#{JobWrapper.name}.perform", job.name, *args)
|
||||
end
|
||||
|
||||
def enqueue_at(job, timestamp, *args)
|
||||
raise NotImplementedError
|
||||
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(timestamp, "#{JobWrapper.name}.perform", job.name, *args)
|
||||
end
|
||||
|
||||
# Builds a <tt>QC::Queue</tt> object to schedule jobs on.
|
||||
#
|
||||
# If you have a custom <tt>QC::Queue</tt> subclass you'll need to suclass
|
||||
# <tt>ActiveJob::QueueAdapters::QueueClassicAdapter</tt> and override the
|
||||
# <tt>build_queue</tt> method.
|
||||
def build_queue(queue_name)
|
||||
QC::Queue.new(queue_name)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -7,5 +7,17 @@ module QC
|
|||
receiver = eval(receiver_str)
|
||||
receiver.send(message, *args)
|
||||
end
|
||||
|
||||
def enqueue_in(seconds, method, *args)
|
||||
receiver_str, _, message = method.rpartition('.')
|
||||
receiver = eval(receiver_str)
|
||||
receiver.send(message, *args)
|
||||
end
|
||||
|
||||
def enqueue_at(not_before, method, *args)
|
||||
receiver_str, _, message = method.rpartition('.')
|
||||
receiver = eval(receiver_str)
|
||||
receiver.send(message, *args)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -113,18 +113,23 @@ Active Job has adapters for the following queueing backends:
|
|||
|
||||
#### Backends Features
|
||||
|
||||
| | Async | Queues | Delayed | Priorities | Timeout | Retries |
|
||||
|-----------------------|-------|---------|---------|-------------|---------|---------|
|
||||
| **Backburner** | Yes | Yes | Yes | Yes | Job | Global |
|
||||
| **Delayed Job** | Yes | Yes | Yes | Job | Global | Global |
|
||||
| **Que** | Yes | Yes | Yes | Job | No | Job |
|
||||
| **Queue Classic** | Yes | Yes | Gem | No | No | No |
|
||||
| **Resque** | Yes | Yes | Gem | Queue | Global | Yes |
|
||||
| **Sidekiq** | Yes | Yes | Yes | Queue | No | Job |
|
||||
| **Sneakers** | Yes | Yes | No | Queue | Queue | No |
|
||||
| **Sucker Punch** | Yes | Yes | Yes | No | No | No |
|
||||
| **Active Job Inline** | No | Yes | N/A | N/A | N/A | N/A |
|
||||
| **Active Job** | Yes | Yes | Yes | No | No | No |
|
||||
| | Async | Queues | Delayed | Priorities | Timeout | Retries |
|
||||
|-----------------------|-------|--------|-----------|------------|---------|---------|
|
||||
| **Backburner** | Yes | Yes | Yes | Yes | Job | Global |
|
||||
| **Delayed Job** | Yes | Yes | Yes | Job | Global | Global |
|
||||
| **Que** | Yes | Yes | Yes | Job | No | Job |
|
||||
| **Queue Classic** | Yes | Yes | No* | No | No | No |
|
||||
| **Resque** | Yes | Yes | Yes (Gem) | Queue | Global | Yes |
|
||||
| **Sidekiq** | Yes | Yes | Yes | Queue | No | Job |
|
||||
| **Sneakers** | Yes | Yes | No | Queue | Queue | No |
|
||||
| **Sucker Punch** | Yes | Yes | No | No | No | No |
|
||||
| **Active Job Inline** | No | Yes | N/A | N/A | N/A | N/A |
|
||||
| **Active Job** | Yes | Yes | Yes | No | No | No |
|
||||
|
||||
NOTE:
|
||||
* Queue Classic does not support Job scheduling. However you can implement this
|
||||
yourself or you can use the queue_classic-later gem. See the documentation for
|
||||
ActiveJob::QueueAdapters::QueueClassicAdapter.
|
||||
|
||||
### Change Backends
|
||||
|
||||
|
|
Loading…
Reference in a new issue