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

Add Sidekiq adapter/wrapper fixes #3

This commit is contained in:
Abdelkader Boudih 2014-05-18 19:02:02 +00:00
parent ce124a19e5
commit a712c07c7f
6 changed files with 31 additions and 3 deletions

View file

@ -3,4 +3,4 @@ source 'https://rubygems.org'
gemspec
gem 'resque'
gem 'sidekiq'

View file

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

View file

@ -1,5 +1,6 @@
require 'active_job/queue_adapters/inline_adapter'
require 'active_job/queue_adapters/resque_adapter'
require 'active_job/queue_adapters/sidekiq_adapter'
module ActiveJob
class Base

View file

@ -0,0 +1,11 @@
module ActiveJob
module JobWrappers
class SidekiqWrapper
include Sidekiq::Worker
def perform(job_name, *args)
job_name.constantize.perform(*args)
end
end
end
end

View file

@ -0,0 +1,14 @@
require 'sidekiq'
require 'active_job/job_wrappers/sidekiq_wrapper'
module ActiveJob
module QueueAdapters
class SidekiqAdapter
class << self
def queue(job, *args)
JobWrappers::SidekiqWrapper.perform_async(job, *args)
end
end
end
end
end

2
test/adapters/sidekiq.rb Normal file
View file

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