Class: ActiveJob::QueueAdapters::SqsAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/active_job/queue_adapters/sqs_adapter.rb,
lib/active_job/queue_adapters/sqs_adapter/params.rb

Overview

Synchronous adapter for Amazon SQS ActiveJob. This adapter queues jobs synchronously (ie blocking).

To use this adapter, set up as:

config.active_job.queue_adapter = :sqs

Direct Known Subclasses

SqsAsyncAdapter

Defined Under Namespace

Classes: Params

Instance Method Summary collapse

Instance Method Details

#enqueue(job) ⇒ Object



18
19
20
# File 'lib/active_job/queue_adapters/sqs_adapter.rb', line 18

def enqueue(job)
  _enqueue(job)
end

#enqueue_after_transaction_commit?Boolean

Returns:

  • (Boolean)


13
14
15
16
# File 'lib/active_job/queue_adapters/sqs_adapter.rb', line 13

def enqueue_after_transaction_commit?
  # can be removed after Rails 8
  true
end

#enqueue_all(jobs) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/active_job/queue_adapters/sqs_adapter.rb', line 27

def enqueue_all(jobs)
  enqueued_count = 0
  jobs.group_by(&:queue_name).each do |queue_name, same_queue_jobs|
    enqueued_count += enqueue_batches(queue_name, same_queue_jobs)
  end
  enqueued_count
end

#enqueue_at(job, timestamp) ⇒ Object



22
23
24
25
# File 'lib/active_job/queue_adapters/sqs_adapter.rb', line 22

def enqueue_at(job, timestamp)
  delay = Params.assured_delay_seconds(timestamp)
  _enqueue(job, nil, delay_seconds: delay)
end