diff options
Diffstat (limited to 'activejob/lib/active_job/queue_adapters/sneakers_adapter.rb')
-rw-r--r-- | activejob/lib/active_job/queue_adapters/sneakers_adapter.rb | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/activejob/lib/active_job/queue_adapters/sneakers_adapter.rb b/activejob/lib/active_job/queue_adapters/sneakers_adapter.rb index 48b3df6a46..6d60a2f303 100644 --- a/activejob/lib/active_job/queue_adapters/sneakers_adapter.rb +++ b/activejob/lib/active_job/queue_adapters/sneakers_adapter.rb @@ -3,29 +3,41 @@ require 'thread' module ActiveJob module QueueAdapters + # == Sneakers adapter for Active Job + # + # A high-performance RabbitMQ background processing framework for Ruby. + # Sneakers is being used in production for both I/O and CPU intensive + # workloads, and have achieved the goals of high-performance and + # 0-maintenance, as designed. + # + # Read more about Sneakers {here}[https://github.com/jondot/sneakers]. + # + # To use Sneakers set the queue_adapter config to +:sneakers+. + # + # Rails.application.config.active_job.queue_adapter = :sneakers class SneakersAdapter @monitor = Monitor.new class << self - def enqueue(job, *args) + def enqueue(job) #:nodoc: @monitor.synchronize do JobWrapper.from_queue job.queue_name - JobWrapper.enqueue ActiveSupport::JSON.encode([ job.name, *args ]) + JobWrapper.enqueue ActiveSupport::JSON.encode(job.serialize) end end - def enqueue_at(job, timestamp, *args) + def enqueue_at(job, timestamp) #:nodoc: raise NotImplementedError end end - class JobWrapper + class JobWrapper #:nodoc: include Sneakers::Worker - from_queue 'active_jobs_default' + from_queue 'default' def work(msg) - job_name, *args = ActiveSupport::JSON.decode(msg) - job_name.constantize.new.execute(*args) + job_data = ActiveSupport::JSON.decode(msg) + Base.execute job_data ack! end end |