diff options
Diffstat (limited to 'lib/active_job')
-rw-r--r-- | lib/active_job/queue_adapter.rb | 15 | ||||
-rw-r--r-- | lib/active_job/queue_adapters/que_adapter.rb | 19 | ||||
-rw-r--r-- | lib/active_job/queue_adapters/queue_classic_adapter.rb | 3 |
3 files changed, 27 insertions, 10 deletions
diff --git a/lib/active_job/queue_adapter.rb b/lib/active_job/queue_adapter.rb index 2033f6fe56..8f2f8b86ea 100644 --- a/lib/active_job/queue_adapter.rb +++ b/lib/active_job/queue_adapter.rb @@ -6,14 +6,13 @@ module ActiveJob mattr_reader(:queue_adapter) { ActiveJob::QueueAdapters::InlineAdapter } def queue_adapter=(name_or_adapter) - case name_or_adapter - when Symbol, String - adapter = load_adapter(name_or_adapter) - else - adapter = name_or_adapter - end - - @@queue_adapter = adapter + @@queue_adapter = \ + case name_or_adapter + when Symbol, String + load_adapter(name_or_adapter) + when Class + name_or_adapter + end end private diff --git a/lib/active_job/queue_adapters/que_adapter.rb b/lib/active_job/queue_adapters/que_adapter.rb new file mode 100644 index 0000000000..6750882b91 --- /dev/null +++ b/lib/active_job/queue_adapters/que_adapter.rb @@ -0,0 +1,19 @@ +require 'que' + +module ActiveJob + module QueueAdapters + class QueAdapter + class << self + def queue(job, *args) + JobWrapper.enqueue job, *args, queue: job.queue_name + end + end + + class JobWrapper < Que::Job + def run(job, *args) + job.new.perform *Parameters.deserialize(args) + end + end + end + end +end diff --git a/lib/active_job/queue_adapters/queue_classic_adapter.rb b/lib/active_job/queue_adapters/queue_classic_adapter.rb index e3392a646e..b82edae977 100644 --- a/lib/active_job/queue_adapters/queue_classic_adapter.rb +++ b/lib/active_job/queue_adapters/queue_classic_adapter.rb @@ -5,8 +5,7 @@ module ActiveJob class QueueClassicAdapter class << self def queue(job, *args) - qc_queue = QC::Queue.new(job.queue_name) - qc_queue.enqueue("ActiveJob::QueueAdapters::QueueClassicAdapter::JobWrapper.perform", job, *args) + QC::Queue.new(job.queue_name).enqueue("#{JobWrapper.name}.perform", job, *args) end end |