diff options
-rw-r--r-- | Gemfile | 3 | ||||
-rw-r--r-- | Rakefile | 4 | ||||
-rw-r--r-- | lib/active_job/base.rb | 2 | ||||
-rw-r--r-- | lib/active_job/job_wrappers/sidekiq_wrapper.rb | 11 | ||||
-rw-r--r-- | lib/active_job/job_wrappers/sucker_punch_wrapper.rb | 11 | ||||
-rw-r--r-- | lib/active_job/queue_adapters/sidekiq_adapter.rb | 14 | ||||
-rw-r--r-- | lib/active_job/queue_adapters/sucker_punch_adapter.rb | 14 | ||||
-rw-r--r-- | lib/active_job/version.rb | 2 | ||||
-rw-r--r-- | test/adapters/sidekiq.rb | 2 | ||||
-rw-r--r-- | test/adapters/sucker_punch.rb | 2 |
10 files changed, 61 insertions, 4 deletions
@@ -3,4 +3,5 @@ source 'https://rubygems.org' gemspec gem 'resque' - +gem 'sidekiq' +gem 'sucker_punch'
\ No newline at end of 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 test_sucker_punch) run_without_aborting(*tasks) end -%w( inline resque ).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'] diff --git a/lib/active_job/base.rb b/lib/active_job/base.rb index 341ea6158b..6cce770466 100644 --- a/lib/active_job/base.rb +++ b/lib/active_job/base.rb @@ -1,5 +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 diff --git a/lib/active_job/job_wrappers/sidekiq_wrapper.rb b/lib/active_job/job_wrappers/sidekiq_wrapper.rb new file mode 100644 index 0000000000..fb728ae0fd --- /dev/null +++ b/lib/active_job/job_wrappers/sidekiq_wrapper.rb @@ -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 diff --git a/lib/active_job/job_wrappers/sucker_punch_wrapper.rb b/lib/active_job/job_wrappers/sucker_punch_wrapper.rb new file mode 100644 index 0000000000..80648792ca --- /dev/null +++ b/lib/active_job/job_wrappers/sucker_punch_wrapper.rb @@ -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 diff --git a/lib/active_job/queue_adapters/sidekiq_adapter.rb b/lib/active_job/queue_adapters/sidekiq_adapter.rb new file mode 100644 index 0000000000..70c4377a23 --- /dev/null +++ b/lib/active_job/queue_adapters/sidekiq_adapter.rb @@ -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 diff --git a/lib/active_job/queue_adapters/sucker_punch_adapter.rb b/lib/active_job/queue_adapters/sucker_punch_adapter.rb new file mode 100644 index 0000000000..8191e5a1df --- /dev/null +++ b/lib/active_job/queue_adapters/sucker_punch_adapter.rb @@ -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 diff --git a/lib/active_job/version.rb b/lib/active_job/version.rb index 0add9779d9..7e646fa3c4 100644 --- a/lib/active_job/version.rb +++ b/lib/active_job/version.rb @@ -1,7 +1,7 @@ require_relative 'gem_version' module ActiveJob - # Returns the version of the currently loaded ActiveRecord as a <tt>Gem::Version</tt> + # Returns the version of the currently loaded ActiveJob as a <tt>Gem::Version</tt> def self.version gem_version end diff --git a/test/adapters/sidekiq.rb b/test/adapters/sidekiq.rb new file mode 100644 index 0000000000..74ce808d55 --- /dev/null +++ b/test/adapters/sidekiq.rb @@ -0,0 +1,2 @@ +require 'sidekiq/testing/inline' +ActiveJob::Base.queue_adapter = ActiveJob::QueueAdapters::SidekiqAdapter diff --git a/test/adapters/sucker_punch.rb b/test/adapters/sucker_punch.rb new file mode 100644 index 0000000000..a373552262 --- /dev/null +++ b/test/adapters/sucker_punch.rb @@ -0,0 +1,2 @@ +require 'sucker_punch/testing/inline' +ActiveJob::Base.queue_adapter = ActiveJob::QueueAdapters::SuckerPunchAdapter |