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:
commit
c6925f52d0
7 changed files with 42 additions and 4 deletions
1
Gemfile
1
Gemfile
|
@ -7,3 +7,4 @@ gem 'resque'
|
|||
gem 'sidekiq'
|
||||
gem 'sucker_punch'
|
||||
gem 'delayed_job'
|
||||
gem 'queue_classic'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -13,7 +13,7 @@ of the request-response cycle, so the user doesn't have to wait on it.
|
|||
The main point is to ensure that all Rails apps will have a job infrastructure
|
||||
in place, even if it's in the form of an "immediate runner". We can then have
|
||||
framework features and other gems build on top of that, without having to worry
|
||||
about API differences between Delayed Job and Resque. Picking your queuing
|
||||
about API differences between Delayed Job and Resque. Picking your queuing
|
||||
backend becomes more of an operational concern, then. And you'll be able to
|
||||
switch between them without having to rewrite your jobs.
|
||||
|
||||
|
@ -83,10 +83,10 @@ We currently have adapters for:
|
|||
* Sidekiq
|
||||
* Sucker Punch
|
||||
* Delayed Job
|
||||
* QueueClassic
|
||||
|
||||
We would like to have adapters for:
|
||||
|
||||
* QueueClassic
|
||||
* Sneakers
|
||||
|
||||
|
||||
|
|
4
Rakefile
4
Rakefile
|
@ -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']
|
||||
|
|
20
lib/active_job/queue_adapters/queue_classic_adapter.rb
Normal file
20
lib/active_job/queue_adapters/queue_classic_adapter.rb
Normal 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
|
2
test/adapters/queue_classic.rb
Normal file
2
test/adapters/queue_classic.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
require 'support/queue_classic/inline'
|
||||
ActiveJob::Base.queue_adapter = :queue_classic
|
11
test/support/queue_classic/inline.rb
Normal file
11
test/support/queue_classic/inline.rb
Normal 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
|
Loading…
Reference in a new issue