1
0
Fork 0
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:
Abdelkader Boudih 2014-05-18 19:20:06 +00:00
parent 53f08f9868
commit 68543de836
6 changed files with 31 additions and 2 deletions

View file

@ -4,3 +4,4 @@ gemspec
gem 'resque'
gem 'sidekiq'
gem 'sucker_punch'

View file

@ -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']

View file

@ -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

View 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

View 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

View file

@ -0,0 +1,2 @@
require 'sucker_punch/testing/inline'
ActiveJob::Base.queue_adapter = ActiveJob::QueueAdapters::SuckerPunchAdapter