class Aws::Rails::SqsActiveJob::Configuration
Use Aws::Rails::SqsActiveJob.config
to access the singleton config instance.
Configuration for AWS SQS ActiveJob.
def client
def client @client ||= Aws::SQS::Client.new(user_agent_suffix: user_agent) end
def config_file
def config_file file = ::Rails.root.join("config/aws_sqs_active_job/#{::Rails.env}.yml") file = ::Rails.root.join('config/aws_sqs_active_job.yml') unless file.exist? file end
def config_file_path(options)
-
(String)
- Configuration path found in environment or YAML file.
def config_file_path(options) options[:config_file] || ENV["AWS_SQS_ACTIVE_JOB_CONFIG_FILE"] end
def file_options(options = {})
def file_options(options = {}) file_path = config_file_path(options) if file_path load_from_file(file_path) else {} end end
def initialize(options = {})
(**options)
-
:client
(SQS::Client
) -- SQS Client to use. A default -
:async_queue_error_handler
(Callable
) -- An error handler -
:message_group_id
(String
) -- -
:config_file
(String
) -- -
:logger
(ActiveSupport::Logger
) -- Logger to use -
:shutdown_timeout
(Integer
) -- -
:visibility_timeout
(Integer
) -- -
:max_messages
(Integer
) -- -
:queues
(Hash[Symbol, String]
) -- A mapping between the
Parameters:
-
options
(Hash
) --
def initialize(options = {}) options[:config_file] ||= config_file if config_file.exist? options = DEFAULTS .merge(file_options(options)) .merge(options) set_attributes(options) end
def load_from_file(file_path)
def load_from_file(file_path) require "erb" opts = YAML.load(ERB.new(File.read(file_path)).result) || {} opts.deep_symbolize_keys end
def queue_url_for(job_queue)
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
def set_attributes(options)
def set_attributes(options) options.keys.each do |opt_name| instance_variable_set("@#{opt_name}", options[opt_name]) end end
def to_h
- Api: - private
def to_h h = {} self.instance_variables.each do |v| v_sym = v.to_s.gsub('@', '').to_sym val = self.instance_variable_get(v) h[v_sym] = val end h end
def to_s
- Api: - private
def to_s to_h.to_s end
def user_agent
def user_agent "ft/aws-sdk-rails-activejob/#{Aws::Rails::VERSION}" end