class ActiveJob::QueueAdapters::SuckerPunchAdapter
Rails.application.config.active_job.queue_adapter = :sucker_punch
To use Sucker Punch set the queue_adapter config to :sucker_punch
.
Read more about Sucker Punch here.
single application (eg. Rails, Sinatra, etc.) process.
hosting on a dedicated server. All queues can run within a
with the memory footprint of having to maintain additional jobs if
This reduces the cost of hosting on a service like Heroku along
Sucker Punch is a single-process Ruby asynchronous processing library.
== Sucker Punch adapter for Active Job
def enqueue(job) #:nodoc:
def enqueue(job) #:nodoc: if JobWrapper.respond_to?(:perform_async) # sucker_punch 2.0 API JobWrapper.perform_async job.serialize else # sucker_punch 1.0 API JobWrapper.new.async.perform job.serialize end end
def enqueue_at(job, timestamp) #:nodoc:
def enqueue_at(job, timestamp) #:nodoc: if JobWrapper.respond_to?(:perform_in) delay = timestamp - Time.current.to_f JobWrapper.perform_in delay, job.serialize else raise NotImplementedError, "sucker_punch 1.0 does not support `enqueued_at`. Please upgrade to version ~> 2.0.0 to enable this behavior." end end