Class: Aws::Rails::SqsActiveJob::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/rails/sqs_active_job/configuration.rb

Overview

Configuration for AWS SQS ActiveJob. Use Aws::Rails::SqsActiveJob.config to access the singleton config instance.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Configuration

Don’t use this method directly: Configuration is a singleton class, use Aws::Rails::SqsActiveJob.config to access the singleton config.

@ option options [Boolean] :retry_standard_errors

If `true`, StandardErrors raised by ActiveJobs are left on the queue
and will be retried (pending the SQS Queue's redrive/DLQ/maximum receive settings).
This behavior overrides the standard Rails ActiveJob
[Retry/Discard for failed jobs](https://guides.rubyonrails.org/active_job_basics.html#retrying-or-discarding-failed-jobs)
behavior.  When set to `true` the retries provided by this will be
on top of any retries configured on the job with `retry_on`.
When `false`, retry behavior is fully configured
through `retry_on`/`discard_on` on the ActiveJobs.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :queues (Hash[Symbol, String])

    A mapping between the active job queue name and the SQS Queue URL. Note: multiple active job queues can map to the same SQS Queue URL.

  • :max_messages (Integer)

    The max number of messages to poll for in a batch.

  • :visibility_timeout (Integer)

    If unset, the visibility timeout configured on the SQS queue will be used. The visibility timeout is the number of seconds that a message will not be processable by any other consumers. You should set this value to be longer than your expected job runtime to prevent other processes from picking up an running job. See the (SQS Visibility Timeout Documentation)

  • :shutdown_timeout (Integer)

    the amount of time to wait for a clean shutdown. Jobs that are unable to complete in this time will not be deleted from the SQS queue and will be retryable after the visibility timeout.

  • :logger (ActiveSupport::Logger)

    Logger to use for the poller.

  • :config_file (String)

    Override file to load configuration from. If not specified will attempt to load from config/aws_sqs_active_job.yml.

  • :message_group_id (String) — default: SqsActiveJobGroup

    The message_group_id to use for queueing messages on a fifo queues. Applies only to jobs queued on FIFO queues. See the (SQS FIFO Documentation)

  • :async_queue_error_handler (Callable)

    An error handler to be called when the async active job adapter experiances an error queueing a job. Only applies when active_job.queue_adapter = :amazon_sqs_async. Called with:

    error, job, job_options
  • :client (SQS::Client)

    SQS Client to use. A default client will be created if none is provided.

  • :excluded_deduplication_keys (Array) — default: ['job_id']

    The type of keys stored in the array should be String or Symbol. Using this option, job_id is implicitly added to the keys.



103
104
105
106
107
108
109
# File 'lib/aws/rails/sqs_active_job/configuration.rb', line 103

def initialize(options = {})
  options[:config_file] ||= config_file if File.exist?(config_file)
  options = DEFAULTS
            .merge(file_options(options))
            .merge(options)
  set_attributes(options)
end

Instance Attribute Details

#excluded_deduplication_keysObject

Returns the value of attribute excluded_deduplication_keys.



40
41
42
# File 'lib/aws/rails/sqs_active_job/configuration.rb', line 40

def excluded_deduplication_keys
  @excluded_deduplication_keys
end

Instance Method Details

#queue_url_for(job_queue) ⇒ Object

Return the queue_url for a given job_queue name

Raises:

  • (ArgumentError)


124
125
126
127
128
129
# File 'lib/aws/rails/sqs_active_job/configuration.rb', line 124

def queue_url_for(job_queue)
  job_queue = job_queue.to_sym
  raise ArgumentError, "No queue defined for #{job_queue}" unless queues.key? job_queue

  queues[job_queue]
end