Class: ActiveJob::QueueAdapters::SqsAdapter
- Inherits:
-
Object
- Object
- ActiveJob::QueueAdapters::SqsAdapter
- Defined in:
- lib/active_job/queue_adapters/sqs_adapter.rb,
lib/active_job/queue_adapters/sqs_adapter/params.rb
Overview
Set in rails config via config.active_job.queue_adapter = :sqs to use the SQS adapter
Direct Known Subclasses
Defined Under Namespace
Classes: Params
Instance Method Summary collapse
- #enqueue(job) ⇒ Object
- #enqueue_after_transaction_commit? ⇒ Boolean
- #enqueue_all(jobs) ⇒ Object
- #enqueue_at(job, timestamp) ⇒ Object
Instance Method Details
#enqueue(job) ⇒ Object
13 14 15 |
# File 'lib/active_job/queue_adapters/sqs_adapter.rb', line 13 def enqueue(job) _enqueue(job) end |
#enqueue_after_transaction_commit? ⇒ Boolean
9 10 11 |
# File 'lib/active_job/queue_adapters/sqs_adapter.rb', line 9 def enqueue_after_transaction_commit? true end |
#enqueue_all(jobs) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/active_job/queue_adapters/sqs_adapter.rb', line 22 def enqueue_all(jobs) enqueued_count = 0 jobs.group_by(&:queue_name).each do |queue_name, same_queue_jobs| queue_url = Aws::Rails::SqsActiveJob.config.queue_url_for(queue_name) = { queue_url: queue_url } same_queue_jobs.each_slice(10) do |chunk| entries = chunk.map do |job| entry = Params.new(job, nil).entry entry[:id] = job.job_id entry[:delay_seconds] = Params.assured_delay_seconds(job.scheduled_at) if job.scheduled_at entry end = .deep_dup [:entries] = entries = Aws::Rails::SqsActiveJob.config.client.() enqueued_count += .successful.count end end enqueued_count end |
#enqueue_at(job, timestamp) ⇒ Object
17 18 19 20 |
# File 'lib/active_job/queue_adapters/sqs_adapter.rb', line 17 def enqueue_at(job, ) delay = Params.assured_delay_seconds() _enqueue(job, nil, delay_seconds: delay) end |