1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #34 from cristianbica/queue_classic-adpater

queue_classic adapter
This commit is contained in:
Rafael Mendonça França 2014-05-19 18:08:44 -03:00
commit c6925f52d0
7 changed files with 42 additions and 4 deletions

View file

@ -7,3 +7,4 @@ gem 'resque'
gem 'sidekiq'
gem 'sucker_punch'
gem 'delayed_job'
gem 'queue_classic'

View file

@ -31,6 +31,9 @@ GEM
minitest (5.3.4)
mono_logger (1.1.0)
multi_json (1.9.3)
pg (0.17.1)
queue_classic (2.2.3)
pg (~> 0.17.0)
rack (1.5.2)
rack-protection (1.5.2)
rack
@ -70,6 +73,7 @@ PLATFORMS
DEPENDENCIES
activejob!
delayed_job
queue_classic
rake
resque
sidekiq

View file

@ -83,10 +83,10 @@ We currently have adapters for:
* Sidekiq
* Sucker Punch
* Delayed Job
* QueueClassic
We would like to have adapters for:
* QueueClassic
* Sneakers

View file

@ -20,11 +20,11 @@ task :default => :test
desc 'Run all adapter tests'
task :test do
tasks = %w(test_inline test_resque test_sidekiq test_sucker_punch test_delayed_job)
tasks = %w(test_inline test_resque test_sidekiq test_sucker_punch test_delayed_job test_queue_classic)
run_without_aborting(*tasks)
end
%w(inline resque sidekiq sucker_punch delayed_job).each do |adapter|
%w(inline resque sidekiq sucker_punch delayed_job queue_classic).each do |adapter|
Rake::TestTask.new("test_#{adapter}") do |t|
t.libs << 'test'
t.test_files = FileList['test/cases/**/*_test.rb']

View file

@ -0,0 +1,20 @@
require 'queue_classic'
module ActiveJob
module QueueAdapters
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)
end
end
class JobWrapper
def self.perform(job, *args)
job.new.perform *Parameters.deserialize(args)
end
end
end
end
end

View file

@ -0,0 +1,2 @@
require 'support/queue_classic/inline'
ActiveJob::Base.queue_adapter = :queue_classic

View file

@ -0,0 +1,11 @@
require 'queue_classic'
module QC
class Queue
def enqueue(method, *args)
receiver_str, _, message = method.rpartition('.')
receiver = eval(receiver_str)
receiver.send(message, *args)
end
end
end