mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
commit
3a233d087a
7 changed files with 55 additions and 5 deletions
1
Gemfile
1
Gemfile
|
@ -8,3 +8,4 @@ gem 'sidekiq'
|
||||||
gem 'sucker_punch'
|
gem 'sucker_punch'
|
||||||
gem 'delayed_job'
|
gem 'delayed_job'
|
||||||
gem 'queue_classic'
|
gem 'queue_classic'
|
||||||
|
gem 'sneakers', '0.1.1.pre'
|
||||||
|
|
14
Gemfile.lock
14
Gemfile.lock
|
@ -20,7 +20,10 @@ GEM
|
||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
thread_safe (~> 0.1)
|
thread_safe (~> 0.1)
|
||||||
tzinfo (~> 1.1)
|
tzinfo (~> 1.1)
|
||||||
|
amq-protocol (1.9.2)
|
||||||
builder (3.2.2)
|
builder (3.2.2)
|
||||||
|
bunny (1.1.9)
|
||||||
|
amq-protocol (>= 1.9.2)
|
||||||
celluloid (0.15.2)
|
celluloid (0.15.2)
|
||||||
timers (~> 1.1.0)
|
timers (~> 1.1.0)
|
||||||
connection_pool (2.0.0)
|
connection_pool (2.0.0)
|
||||||
|
@ -47,18 +50,28 @@ GEM
|
||||||
redis-namespace (~> 1.2)
|
redis-namespace (~> 1.2)
|
||||||
sinatra (>= 0.9.2)
|
sinatra (>= 0.9.2)
|
||||||
vegas (~> 0.1.2)
|
vegas (~> 0.1.2)
|
||||||
|
serverengine (1.5.7)
|
||||||
|
sigdump (~> 0.2.2)
|
||||||
sidekiq (3.0.2)
|
sidekiq (3.0.2)
|
||||||
celluloid (>= 0.15.2)
|
celluloid (>= 0.15.2)
|
||||||
connection_pool (>= 2.0.0)
|
connection_pool (>= 2.0.0)
|
||||||
json
|
json
|
||||||
redis (>= 3.0.6)
|
redis (>= 3.0.6)
|
||||||
redis-namespace (>= 1.3.1)
|
redis-namespace (>= 1.3.1)
|
||||||
|
sigdump (0.2.2)
|
||||||
sinatra (1.4.4)
|
sinatra (1.4.4)
|
||||||
rack (~> 1.4)
|
rack (~> 1.4)
|
||||||
rack-protection (~> 1.4)
|
rack-protection (~> 1.4)
|
||||||
tilt (~> 1.3, >= 1.3.4)
|
tilt (~> 1.3, >= 1.3.4)
|
||||||
|
sneakers (0.1.1.pre)
|
||||||
|
bunny (~> 1.1.3)
|
||||||
|
serverengine
|
||||||
|
thor
|
||||||
|
thread
|
||||||
sucker_punch (1.0.5)
|
sucker_punch (1.0.5)
|
||||||
celluloid (~> 0.15.2)
|
celluloid (~> 0.15.2)
|
||||||
|
thor (0.19.1)
|
||||||
|
thread (0.1.4)
|
||||||
thread_safe (0.3.3)
|
thread_safe (0.3.3)
|
||||||
tilt (1.4.1)
|
tilt (1.4.1)
|
||||||
timers (1.1.0)
|
timers (1.1.0)
|
||||||
|
@ -77,4 +90,5 @@ DEPENDENCIES
|
||||||
rake
|
rake
|
||||||
resque
|
resque
|
||||||
sidekiq
|
sidekiq
|
||||||
|
sneakers (= 0.1.1.pre)
|
||||||
sucker_punch
|
sucker_punch
|
||||||
|
|
|
@ -84,9 +84,6 @@ We currently have adapters for:
|
||||||
* Sucker Punch
|
* Sucker Punch
|
||||||
* Delayed Job
|
* Delayed Job
|
||||||
* QueueClassic
|
* QueueClassic
|
||||||
|
|
||||||
We would like to have adapters for:
|
|
||||||
|
|
||||||
* Sneakers
|
* Sneakers
|
||||||
|
|
||||||
|
|
||||||
|
|
4
Rakefile
4
Rakefile
|
@ -20,11 +20,11 @@ task :default => :test
|
||||||
|
|
||||||
desc 'Run all adapter tests'
|
desc 'Run all adapter tests'
|
||||||
task :test do
|
task :test do
|
||||||
tasks = %w(test_inline test_resque test_sidekiq test_sucker_punch test_delayed_job test_queue_classic)
|
tasks = %w(test_inline test_resque test_sidekiq test_sucker_punch test_delayed_job test_queue_classic test_sneakers)
|
||||||
run_without_aborting(*tasks)
|
run_without_aborting(*tasks)
|
||||||
end
|
end
|
||||||
|
|
||||||
%w(inline resque sidekiq sucker_punch delayed_job queue_classic).each do |adapter|
|
%w(inline resque sidekiq sucker_punch delayed_job queue_classic sneakers).each do |adapter|
|
||||||
Rake::TestTask.new("test_#{adapter}") do |t|
|
Rake::TestTask.new("test_#{adapter}") do |t|
|
||||||
t.libs << 'test'
|
t.libs << 'test'
|
||||||
t.test_files = FileList['test/cases/**/*_test.rb']
|
t.test_files = FileList['test/cases/**/*_test.rb']
|
||||||
|
|
24
lib/active_job/queue_adapters/sneakers_adapter.rb
Normal file
24
lib/active_job/queue_adapters/sneakers_adapter.rb
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
require 'sneakers'
|
||||||
|
|
||||||
|
module ActiveJob
|
||||||
|
module QueueAdapters
|
||||||
|
class SneakersAdapter
|
||||||
|
class << self
|
||||||
|
def queue(job, *args)
|
||||||
|
JobWrapper.enqueue([job, *args])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class JobWrapper
|
||||||
|
include Sneakers::Worker
|
||||||
|
|
||||||
|
self.from_queue("queue", {})
|
||||||
|
|
||||||
|
def work(*args)
|
||||||
|
job_name = args.shift
|
||||||
|
job_name.new.perform *Parameters.deserialize(args)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
2
test/adapters/sneakers.rb
Normal file
2
test/adapters/sneakers.rb
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
require 'support/sneakers/inline'
|
||||||
|
ActiveJob::Base.queue_adapter = :sneakers
|
12
test/support/sneakers/inline.rb
Normal file
12
test/support/sneakers/inline.rb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
require 'sneakers'
|
||||||
|
|
||||||
|
module Sneakers
|
||||||
|
module Worker
|
||||||
|
module ClassMethods
|
||||||
|
def enqueue(msg)
|
||||||
|
worker = self.new(nil, nil, {})
|
||||||
|
worker.work(*msg)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue