lib/sqewer/extensions/active_job_adapter.rb in sqewer-6.0.4 vs lib/sqewer/extensions/active_job_adapter.rb in sqewer-6.0.5

- old
+ new

@@ -6,16 +6,18 @@ if ActiveJob::VERSION::MAJOR <= 4 module Execution prepend PerformWithKeywords end end + module QueueAdapters # Handle Rails ActiveJob through sqewer. # Set it up like so: # # Rails.application.config.active_job.queue_adapter = :sqewer class SqewerAdapter + # Works as a Job for sqewer, and wraps an ActiveJob Worker which responds to perform() class Performable # Creates a new Performable using the passed ActiveJob object. The resulting Performable # can be sent to any Sqewer queue. @@ -65,23 +67,21 @@ defined?(ActiveRecord) && ActiveRecord::Base.connected? end end - class << self - def enqueue(active_job) #:nodoc: - wrapped_job = Performable.from_active_job(active_job) + def enqueue(active_job) #:nodoc: + wrapped_job = Performable.from_active_job(active_job) - Sqewer.submit!(wrapped_job) - end + Sqewer.submit!(wrapped_job) + end - def enqueue_at(active_job, timestamp) #:nodoc: - wrapped_job = Performable.from_active_job(active_job) + def enqueue_at(active_job, timestamp) #:nodoc: + wrapped_job = Performable.from_active_job(active_job) - delta_t = (timestamp - Time.now.to_i).to_i + delta_t = (timestamp - Time.now.to_i).to_i - Sqewer.submit!(wrapped_job, delay_seconds: delta_t) - end + Sqewer.submit!(wrapped_job, delay_seconds: delta_t) end end end end