module ActiveJob module QueueAdapters # Rails.application.config.active_job.queue_adapter = :beaneater class ActiveBeaneaterAdapter class << self def enqueue(job) #:nodoc: enqueue_at(job, nil) end def enqueue_at(job, timestamp) #:nodoc: delay = timestamp ? timestamp - Time.current.to_f : 0 tube = client.tubes[ActiveBeaneater.resolve_queue_name(job.queue_name)] pri = job.respond_to?(:queue_priority_number) ? job.queue_priority_number : 0 ttr = job.respond_to?(:queue_respond_timeout) ? job.queue_respond_timeout : 10.minutes tube.put(job.serialize.to_json, delay: delay, pri: pri, ttr: ttr) end private def client Rails.application.config.beaneater.client end end end end end