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

Direct Known Subclasses

ShoryukenConcurrentSendAdapter

Defined Under Namespace

Classes: JobWrapper

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.enqueue(job) ⇒ Object


24
25
26
# File 'lib/shoryuken/extensions/active_job_adapter.rb', line 24

def enqueue(job)
  instance.enqueue(job)
end

.enqueue_at(job, timestamp) ⇒ Object


28
29
30
# File 'lib/shoryuken/extensions/active_job_adapter.rb', line 28

def enqueue_at(job, timestamp)
  instance.enqueue_at(job, timestamp)
end

.instanceObject


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

def instance
  # https://github.com/phstc/shoryuken/pull/174#issuecomment-174555657
  @instance ||= new
end

Instance Method Details

#enqueue(job, options = {}) ⇒ Object

:nodoc:


33
34
35
36
37
38
# File 'lib/shoryuken/extensions/active_job_adapter.rb', line 33

def enqueue(job, options = {}) #:nodoc:
  register_worker!(job)

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

#enqueue_at(job, timestamp) ⇒ Object

:nodoc:


40
41
42
# File 'lib/shoryuken/extensions/active_job_adapter.rb', line 40

def enqueue_at(job, timestamp) #:nodoc:
  enqueue(job, delay_seconds: calculate_delay(timestamp))
end