mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add Sucker Punch adapter/wrapper
This commit is contained in:
parent
53f08f9868
commit
68543de836
6 changed files with 31 additions and 2 deletions
1
Gemfile
1
Gemfile
|
@ -4,3 +4,4 @@ gemspec
|
|||
|
||||
gem 'resque'
|
||||
gem 'sidekiq'
|
||||
gem 'sucker_punch'
|
4
Rakefile
4
Rakefile
|
@ -22,12 +22,12 @@ task :default => :test
|
|||
|
||||
desc 'Run all adapter tests'
|
||||
task :test do
|
||||
tasks = %w(test_inline test_resque test_sidekiq)
|
||||
tasks = %w(test_inline test_resque test_sidekiq test_sucker_punch)
|
||||
run_without_aborting(*tasks)
|
||||
end
|
||||
|
||||
|
||||
%w( inline resque sidekiq ).each do |adapter|
|
||||
%w( inline resque sidekiq sucker_punch).each do |adapter|
|
||||
Rake::TestTask.new("test_#{adapter}") do |t|
|
||||
t.libs << 'test'
|
||||
t.test_files = FileList['test/cases/**/*_test.rb']
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
require 'active_job/queue_adapters/inline_adapter'
|
||||
require 'active_job/queue_adapters/resque_adapter'
|
||||
require 'active_job/queue_adapters/sidekiq_adapter'
|
||||
require 'active_job/queue_adapters/sucker_punch_adapter'
|
||||
|
||||
module ActiveJob
|
||||
class Base
|
||||
|
|
11
lib/active_job/job_wrappers/sucker_punch_wrapper.rb
Normal file
11
lib/active_job/job_wrappers/sucker_punch_wrapper.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
module ActiveJob
|
||||
module JobWrappers
|
||||
class SuckerPunchWrapper
|
||||
include SuckerPunch::Job
|
||||
|
||||
def perform(job_name, *args)
|
||||
job_name.perform(*args)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
14
lib/active_job/queue_adapters/sucker_punch_adapter.rb
Normal file
14
lib/active_job/queue_adapters/sucker_punch_adapter.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
require 'sucker_punch'
|
||||
require 'active_job/job_wrappers/sucker_punch_wrapper'
|
||||
|
||||
module ActiveJob
|
||||
module QueueAdapters
|
||||
class SuckerPunchAdapter
|
||||
class << self
|
||||
def queue(job, *args)
|
||||
JobWrappers::SuckerPunchWrapper.new.async.perform(job, *args)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
2
test/adapters/sucker_punch.rb
Normal file
2
test/adapters/sucker_punch.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
require 'sucker_punch/testing/inline'
|
||||
ActiveJob::Base.queue_adapter = ActiveJob::QueueAdapters::SuckerPunchAdapter
|
Loading…
Reference in a new issue