mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #43 from mytrile/master
Adding backburner(beanstalks client) adapter
This commit is contained in:
commit
207ca30946
7 changed files with 47 additions and 3 deletions
3
Gemfile
3
Gemfile
|
@ -9,4 +9,5 @@ gem 'sucker_punch'
|
|||
gem 'delayed_job'
|
||||
gem 'queue_classic'
|
||||
gem 'sneakers', '0.1.1.pre'
|
||||
gem 'que'
|
||||
gem 'que'
|
||||
gem 'backburner'
|
||||
|
|
|
@ -21,12 +21,17 @@ GEM
|
|||
thread_safe (~> 0.1)
|
||||
tzinfo (~> 1.1)
|
||||
amq-protocol (1.9.2)
|
||||
backburner (0.4.5)
|
||||
beaneater (~> 0.3.1)
|
||||
dante (~> 0.1.5)
|
||||
beaneater (0.3.2)
|
||||
builder (3.2.2)
|
||||
bunny (1.1.9)
|
||||
amq-protocol (>= 1.9.2)
|
||||
celluloid (0.15.2)
|
||||
timers (~> 1.1.0)
|
||||
connection_pool (2.0.0)
|
||||
dante (0.1.5)
|
||||
delayed_job (4.0.1)
|
||||
activesupport (>= 3.0, < 4.2)
|
||||
i18n (0.6.9)
|
||||
|
@ -86,6 +91,7 @@ PLATFORMS
|
|||
|
||||
DEPENDENCIES
|
||||
activejob!
|
||||
backburner
|
||||
delayed_job
|
||||
que
|
||||
queue_classic
|
||||
|
|
4
Rakefile
4
Rakefile
|
@ -20,11 +20,11 @@ task :default => :test
|
|||
|
||||
desc 'Run all adapter tests'
|
||||
task :test do
|
||||
tasks = %w(test_inline test_delayed_job test_que test_queue_classic test_resque test_sidekiq test_sneakers test_sucker_punch)
|
||||
tasks = %w(test_inline test_delayed_job test_que test_queue_classic test_resque test_sidekiq test_sneakers test_sucker_punch test_backburner)
|
||||
run_without_aborting(*tasks)
|
||||
end
|
||||
|
||||
%w(inline delayed_job que queue_classic resque sidekiq sneakers sucker_punch).each do |adapter|
|
||||
%w(inline delayed_job que queue_classic resque sidekiq sneakers sucker_punch backburner).each do |adapter|
|
||||
Rake::TestTask.new("test_#{adapter}") do |t|
|
||||
t.libs << 'test'
|
||||
t.test_files = FileList['test/cases/**/*_test.rb']
|
||||
|
|
21
lib/active_job/queue_adapters/backburner_adapter.rb
Normal file
21
lib/active_job/queue_adapters/backburner_adapter.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
require 'backburner'
|
||||
|
||||
module ActiveJob
|
||||
module QueueAdapters
|
||||
class BackburnerAdapter
|
||||
class << self
|
||||
def queue(job, *args)
|
||||
Backburner::Worker.enqueue JobWrapper, [ job.name, *args ], queue: job.queue_name
|
||||
end
|
||||
end
|
||||
|
||||
class JobWrapper
|
||||
class << self
|
||||
def perform(job_name, *args)
|
||||
job_name.constantize.new.perform *Parameters.deserialize(args)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
3
test/adapters/backburner.rb
Normal file
3
test/adapters/backburner.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
require 'support/backburner/inline'
|
||||
|
||||
ActiveJob::Base.queue_adapter = :backburner
|
|
@ -43,4 +43,9 @@ class AdapterTest < ActiveSupport::TestCase
|
|||
ActiveJob::Base.queue_adapter = :sneakers
|
||||
assert_equal ActiveJob::QueueAdapters::SneakersAdapter, ActiveJob::Base.queue_adapter
|
||||
end
|
||||
|
||||
test 'should load Backburner adapter' do
|
||||
ActiveJob::Base.queue_adapter = :backburner
|
||||
assert_equal ActiveJob::QueueAdapters::BackburnerAdapter, ActiveJob::Base.queue_adapter
|
||||
end
|
||||
end
|
||||
|
|
8
test/support/backburner/inline.rb
Normal file
8
test/support/backburner/inline.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
require 'backburner'
|
||||
|
||||
Backburner::Worker.class_eval do
|
||||
class << self; alias_method :original_enqueue, :enqueue; end
|
||||
def self.enqueue(job_class, args=[], opts={})
|
||||
job_class.perform(*args)
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue