diff options
Diffstat (limited to 'lib/active_job')
-rw-r--r-- | lib/active_job/base.rb | 2 | ||||
-rw-r--r-- | lib/active_job/queue_adapters/qu_adapter.rb | 28 | ||||
-rw-r--r-- | lib/active_job/queue_name.rb | 16 |
3 files changed, 41 insertions, 5 deletions
diff --git a/lib/active_job/base.rb b/lib/active_job/base.rb index 0c772e3126..d5ba253016 100644 --- a/lib/active_job/base.rb +++ b/lib/active_job/base.rb @@ -9,8 +9,8 @@ require 'active_job/logging' module ActiveJob class Base extend QueueAdapter - extend QueueName + include QueueName include Enqueuing include Execution include Callbacks diff --git a/lib/active_job/queue_adapters/qu_adapter.rb b/lib/active_job/queue_adapters/qu_adapter.rb new file mode 100644 index 0000000000..7e69229801 --- /dev/null +++ b/lib/active_job/queue_adapters/qu_adapter.rb @@ -0,0 +1,28 @@ +require 'qu' + +module ActiveJob + module QueueAdapters + class QuAdapter + class << self + def enqueue(job, *args) + Qu::Payload.new(klass: JobWrapper, args: [job, *args], queue: job.queue_name).push + end + + def enqueue_at(job, timestamp, *args) + raise NotImplementedError + end + end + + class JobWrapper < Qu::Job + def initialize(job, *args) + @job = job + @args = args + end + + def perform + @job.new.execute *@args + end + end + end + end +end diff --git a/lib/active_job/queue_name.rb b/lib/active_job/queue_name.rb index a606b67370..859ddad034 100644 --- a/lib/active_job/queue_name.rb +++ b/lib/active_job/queue_name.rb @@ -1,10 +1,18 @@ module ActiveJob module QueueName - mattr_accessor(:queue_base_name) { "active_jobs" } - mattr_accessor(:queue_name) { queue_base_name } + extend ActiveSupport::Concern - def queue_as(part_name) - self.queue_name = "#{queue_base_name}_#{part_name}" + module ClassMethods + mattr_accessor(:queue_base_name) { "active_jobs" } + + def queue_as(part_name) + self.queue_name = "#{queue_base_name}_#{part_name}" + end + end + + included do + class_attribute :queue_name + self.queue_name = queue_base_name end end end
\ No newline at end of file |