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

Merge pull request #37 from Aesthetikx/master

Add Sneakers wrapper
This commit is contained in:
Guillermo Iguaran 2014-05-19 23:23:02 -05:00
commit 3a233d087a
7 changed files with 55 additions and 5 deletions

View file

@ -8,3 +8,4 @@ gem 'sidekiq'
gem 'sucker_punch'
gem 'delayed_job'
gem 'queue_classic'
gem 'sneakers', '0.1.1.pre'

View file

@ -20,7 +20,10 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
amq-protocol (1.9.2)
builder (3.2.2)
bunny (1.1.9)
amq-protocol (>= 1.9.2)
celluloid (0.15.2)
timers (~> 1.1.0)
connection_pool (2.0.0)
@ -47,18 +50,28 @@ GEM
redis-namespace (~> 1.2)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
serverengine (1.5.7)
sigdump (~> 0.2.2)
sidekiq (3.0.2)
celluloid (>= 0.15.2)
connection_pool (>= 2.0.0)
json
redis (>= 3.0.6)
redis-namespace (>= 1.3.1)
sigdump (0.2.2)
sinatra (1.4.4)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
sneakers (0.1.1.pre)
bunny (~> 1.1.3)
serverengine
thor
thread
sucker_punch (1.0.5)
celluloid (~> 0.15.2)
thor (0.19.1)
thread (0.1.4)
thread_safe (0.3.3)
tilt (1.4.1)
timers (1.1.0)
@ -77,4 +90,5 @@ DEPENDENCIES
rake
resque
sidekiq
sneakers (= 0.1.1.pre)
sucker_punch

View file

@ -84,9 +84,6 @@ We currently have adapters for:
* Sucker Punch
* Delayed Job
* QueueClassic
We would like to have adapters for:
* Sneakers

View file

@ -20,11 +20,11 @@ task :default => :test
desc 'Run all adapter tests'
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)
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|
t.libs << 'test'
t.test_files = FileList['test/cases/**/*_test.rb']

View 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

View file

@ -0,0 +1,2 @@
require 'support/sneakers/inline'
ActiveJob::Base.queue_adapter = :sneakers

View 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