AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

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 Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Configuration

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

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)

    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.



85
86
87
88
89
90
91
# File 'lib/aws/rails/sqs_active_job/configuration.rb', line 85

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

Instance Method Details

#queue_url_for(job_queue) ⇒ Object

Return the queue_url for a given job_queue name

Raises:

  • (ArgumentError)


98
99
100
101
102
103
# File 'lib/aws/rails/sqs_active_job/configuration.rb', line 98

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.to_sym]
end