Class: ActiveJob::QueueAdapters::SqsAdapter::Params

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

Overview

build request parameter of Aws::SQS::Client

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job, body) ⇒ Params

Returns a new instance of Params.



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

def initialize(job, body)
  @job = job
  @body = body || job.serialize
end

Class Method Details

.assured_delay_seconds(timestamp) ⇒ Object

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
# File 'lib/active_job/queue_adapters/sqs_adapter/params.rb', line 9

def assured_delay_seconds(timestamp)
  delay = (timestamp - Time.now.to_f).floor
  delay = 0 if delay.negative?
  raise ArgumentError, 'Unable to queue a job with a delay great than 15 minutes' if delay > 15.minutes

  delay
end

Instance Method Details

#entryObject



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

def entry
  if Aws::Rails::SqsActiveJob.fifo?(queue_url)
    default_entry.merge(options_for_fifo)
  else
    default_entry
  end
end

#queue_urlObject



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

def queue_url
  @queue_url ||= Aws::Rails::SqsActiveJob.config.queue_url_for(@job.queue_name)
end