Class: ActiveJob::QueueAdapters::ConeyIslandAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/coney_island/coney_island_adapter.rb

Instance Method Summary collapse

Instance Method Details

#enqueue(job) ⇒ Object

ConeyIsland adapter for Active Job

ConeyIsland is an industrial-strength background worker system for Rails using RabbitMQ. Read more about here.

To use ConeyIsland set the queue_adapter config to :coney_island.

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


12
13
14
15
# File 'lib/coney_island/coney_island_adapter.rb', line 12

def enqueue(job) #:nodoc:
  ConeyIsland::Submitter.submit job.class, :perform, args: job.arguments, work_queue: job.queue_name, timeout: get_timeout_from_args(job),
    retry_limit: get_retry_from_args(job), singleton: true
end

#enqueue_at(job, timestamp) ⇒ Object

:nodoc:



17
18
19
20
21
22
23
24
25
# File 'lib/coney_island/coney_island_adapter.rb', line 17

def enqueue_at(job, timestamp) #:nodoc:
  params = {args: job.arguments, work_queue: job.queue_name, timeout: get_timeout_from_args(job),
    retry_limit: get_retry_from_args(job), singleton: true}
  delay = timestamp - Time.current.to_f
  if delay > 0
    params[:delay] = delay.round
  end
  ConeyIsland::Submitter.submit job.class, :perform, params
end

#get_retry_from_args(job) ⇒ Object



31
32
33
# File 'lib/coney_island/coney_island_adapter.rb', line 31

def get_retry_from_args(job)
  job.class::RETRY_LIMIT if job.class.const_defined? :RETRY_LIMIT
end

#get_timeout_from_args(job) ⇒ Object



27
28
29
# File 'lib/coney_island/coney_island_adapter.rb', line 27

def get_timeout_from_args(job)
  job.class::TIMEOUT if job.class.const_defined? :TIMEOUT
end