diff options
author | David Heinemeier Hansson <david@basecamp.com> | 2014-08-06 15:11:22 -0700 |
---|---|---|
committer | David Heinemeier Hansson <david@basecamp.com> | 2014-08-06 15:11:22 -0700 |
commit | 06ccd5f405a004275915102eb3ccc42b952ba549 (patch) | |
tree | ea847a54322421e608da96440e6622dc5f20e28f /lib/active_job | |
parent | 38ee4fd8d3c46616bc8a09f7486de4a5069df91a (diff) | |
parent | 6ff5972c0db45c192af9c0d056d786c61821f29f (diff) | |
download | rails-06ccd5f405a004275915102eb3ccc42b952ba549.tar.gz rails-06ccd5f405a004275915102eb3ccc42b952ba549.tar.bz2 rails-06ccd5f405a004275915102eb3ccc42b952ba549.zip |
Merge pull request #103 from cristianbica/adapter-fixes
Fixed qu, queue_classic, sneakers adapters
Diffstat (limited to 'lib/active_job')
-rw-r--r-- | lib/active_job/queue_adapters/qu_adapter.rb | 8 | ||||
-rw-r--r-- | lib/active_job/queue_adapters/queue_classic_adapter.rb | 6 | ||||
-rw-r--r-- | lib/active_job/queue_adapters/sneakers_adapter.rb | 8 |
3 files changed, 13 insertions, 9 deletions
diff --git a/lib/active_job/queue_adapters/qu_adapter.rb b/lib/active_job/queue_adapters/qu_adapter.rb index 7e69229801..cdf4ae4ce9 100644 --- a/lib/active_job/queue_adapters/qu_adapter.rb +++ b/lib/active_job/queue_adapters/qu_adapter.rb @@ -5,7 +5,9 @@ module ActiveJob class QuAdapter class << self def enqueue(job, *args) - Qu::Payload.new(klass: JobWrapper, args: [job, *args], queue: job.queue_name).push + Qu::Payload.new(klass: JobWrapper, args: [job.name, *args]).tap do |payload| + payload.instance_variable_set(:@queue, job.queue_name) + end.push end def enqueue_at(job, timestamp, *args) @@ -14,8 +16,8 @@ module ActiveJob end class JobWrapper < Qu::Job - def initialize(job, *args) - @job = job + def initialize(job_name, *args) + @job = job_name.constantize @args = args end diff --git a/lib/active_job/queue_adapters/queue_classic_adapter.rb b/lib/active_job/queue_adapters/queue_classic_adapter.rb index db7189f076..c61e0e30db 100644 --- a/lib/active_job/queue_adapters/queue_classic_adapter.rb +++ b/lib/active_job/queue_adapters/queue_classic_adapter.rb @@ -5,7 +5,7 @@ module ActiveJob class QueueClassicAdapter class << self def enqueue(job, *args) - QC::Queue.new(job.queue_name).enqueue("#{JobWrapper.name}.perform", job, *args) + QC::Queue.new(job.queue_name).enqueue("#{JobWrapper.name}.perform", job.name, *args) end def enqueue_at(job, timestamp, *args) @@ -14,8 +14,8 @@ module ActiveJob end class JobWrapper - def self.perform(job, *args) - job.new.execute *args + def self.perform(job_name, *args) + job_name.constantize.new.execute *args end end end diff --git a/lib/active_job/queue_adapters/sneakers_adapter.rb b/lib/active_job/queue_adapters/sneakers_adapter.rb index f7da691935..094b128547 100644 --- a/lib/active_job/queue_adapters/sneakers_adapter.rb +++ b/lib/active_job/queue_adapters/sneakers_adapter.rb @@ -10,7 +10,7 @@ module ActiveJob def enqueue(job, *args) @monitor.synchronize do JobWrapper.from_queue job.queue_name - JobWrapper.enqueue [ job, *args ] + JobWrapper.enqueue ActiveSupport::JSON.encode([ job.name, *args ]) end end @@ -22,8 +22,10 @@ module ActiveJob class JobWrapper include Sneakers::Worker - def work(job, *args) - job.new.execute *args + def work(msg) + job_name, *args = ActiveSupport::JSON.decode(msg) + job_name.constantize.new.execute *args + ack! end end end |