Class: ActiveJob::QueueAdapters::ShoryukenAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/shoryuken/extensions/active_job_adapter.rb

Overview

Shoryuken adapter for Active Job

Shoryuken (“sho-ryu-ken”) is a super-efficient AWS SQS thread based message processor.

Read more about Shoryuken here.

To use Shoryuken set the queue_adapter config to :shoryuken.

Rails.application.config.active_job.queue_adapter = :shoryuken

Defined Under Namespace

Classes: JobWrapper

Class Method Summary collapse

Class Method Details

.enqueue(job) ⇒ Object

:nodoc:


19
20
21
22
23
24
# File 'lib/shoryuken/extensions/active_job_adapter.rb', line 19

def enqueue(job) #:nodoc:
  register_worker!(job)

  queue = Shoryuken::Client.queues(job.queue_name)
  queue.send_message(message(job))
end

.enqueue_at(job, timestamp) ⇒ Object

:nodoc:


26
27
28
29
30
31
32
33
34
# File 'lib/shoryuken/extensions/active_job_adapter.rb', line 26

def enqueue_at(job, timestamp) #:nodoc:
  register_worker!(job)

  delay = (timestamp - Time.current.to_f).round
  raise 'The maximum allowed delay is 15 minutes' if delay > 15.minutes

  queue = Shoryuken::Client.queues(job.queue_name)
  queue.send_message(message(job, delay_seconds: delay))
end