Class: Aws::ActiveJob::SQS::Configuration
- Inherits:
-
Object
- Object
- Aws::ActiveJob::SQS::Configuration
- Defined in:
- lib/aws/active_job/sqs/configuration.rb
Overview
This class provides a Configuration object for AWS ActiveJob by pulling configuration options from runtime code, the ENV, a YAML file, and default settings, in that order. Values set on queues are used preferentially to global values.
Use Aws::ActiveJob::SQS.config to access the singleton config instance and use Aws::ActiveJob::SQS.configure to configure in code:
Aws::ActiveJob::SQS.configure do |config|
config.logger = Rails.logger
config. = 5
end
# Configuation YAML File By default, this class will load configuration from the ‘config/aws_active_job_sqs/<RAILS_ENV}.yml` or `config/aws_active_job_sqs.yml` files. You may specify the file used through the `:config_file` option in code or the `AWS_ACTIVE_JOB_SQS_CONFIG_FILE` environment variable.
# Global and queue specific options Values configured for specific queues are used preferentially to global values. See: QUEUE_CONFIGS for supported queue specific options.
# Environment Variables The Configuration loads global and qubeue specific values from your environment. Global keys take the form of: ‘AWS_ACTIVE_JOB_SQS_<KEY_NAME>` and queue specific keys take the form of: `AWS_ACTIVE_JOB_SQS_<QUEUE_NAME>_<KEY_NAME>`. <QUEUE_NAME> is case-insensitive and is always down cased. Configuring non-snake case queues (containing upper case) through ENV is not supported.
Example:
export AWS_ACTIVE_JOB_SQS_MAX_MESSAGES = 5
export AWS_ACTIVE_JOB_SQS_DEFAULT_URL = https://my-queue.aws
For supported global ENV configurations see GLOBAL_ENV_CONFIGS. For supported queue specific ENV configurations see: QUEUE_ENV_CONFIGS.
Constant Summary collapse
- DEFAULTS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Default configuration options
{ threads: 2 * Concurrent.processor_count, backpressure: 10, max_messages: 10, shutdown_timeout: 15, queues: Hash.new { |h, k| h[k] = {} }, message_group_id: 'ActiveJobSqsGroup', excluded_deduplication_keys: ['job_id'] }.freeze
- GLOBAL_ENV_CONFIGS =
%i[ config_file threads backpressure max_messages shutdown_timeout visibility_timeout message_group_id ].freeze
- QUEUE_ENV_CONFIGS =
%i[ url max_messages visibility_timeout message_group_id ].freeze
- QUEUE_CONFIGS =
QUEUE_ENV_CONFIGS + %i[excluded_deduplication_keys]
- QUEUE_KEY_REGEX =
/AWS_ACTIVE_JOB_SQS_([\w]+)_(#{QUEUE_ENV_CONFIGS.map(&:upcase).join('|')})/.freeze
Instance Attribute Summary collapse
- #async_queue_error_handler ⇒ Object private
- #backpressure ⇒ Object private
- #client ⇒ Object
- #logger ⇒ Object private
- #max_messages ⇒ Object writeonly private
- #message_group_id ⇒ Object writeonly private
- #poller_error_handler(&block) ⇒ Object
- #queues ⇒ Object private
- #shutdown_timeout ⇒ Object private
- #threads ⇒ Object private
- #visibility_timeout ⇒ Object writeonly private
Instance Method Summary collapse
- #excluded_deduplication_keys=(keys) ⇒ Object
-
#initialize(options = {}) ⇒ Configuration
constructor
Don’t use this method directly: Configuration is a singleton class, use Aws::ActiveJob::SQS.config to access the singleton config instance and use Aws::ActiveJob::SQS.configure to configure in code:.
- #to_h ⇒ Object private
- #to_s ⇒ Object private
Constructor Details
#initialize(options = {}) ⇒ Configuration
Don’t use this method directly: Configuration is a singleton class, use Aws::ActiveJob::SQS.config to access the singleton config instance and use Aws::ActiveJob::SQS.configure to configure in code:
152 153 154 155 156 157 158 |
# File 'lib/aws/active_job/sqs/configuration.rb', line 152 def initialize( = {}) opts = .deep_merge() opts = (opts).deep_merge(opts) opts = DEFAULTS.merge(logger: default_logger).deep_merge(opts) apply_attributes(opts) end |
Instance Attribute Details
#async_queue_error_handler ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
161 162 163 |
# File 'lib/aws/active_job/sqs/configuration.rb', line 161 def async_queue_error_handler @async_queue_error_handler end |
#backpressure ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
161 162 163 |
# File 'lib/aws/active_job/sqs/configuration.rb', line 161 def backpressure @backpressure end |
#client ⇒ Object
178 179 180 181 182 183 184 |
# File 'lib/aws/active_job/sqs/configuration.rb', line 178 def client @client ||= begin client = Aws::SQS::Client.new client.config.user_agent_frameworks << 'aws-activejob-sqs' client end end |
#logger ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
161 162 163 |
# File 'lib/aws/active_job/sqs/configuration.rb', line 161 def logger @logger end |
#max_messages=(value) ⇒ Object (writeonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
166 167 168 |
# File 'lib/aws/active_job/sqs/configuration.rb', line 166 def (value) @max_messages = value end |
#message_group_id=(value) ⇒ Object (writeonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
166 167 168 |
# File 'lib/aws/active_job/sqs/configuration.rb', line 166 def (value) @message_group_id = value end |
#poller_error_handler(&block) ⇒ Object
173 174 175 176 |
# File 'lib/aws/active_job/sqs/configuration.rb', line 173 def poller_error_handler(&block) @poller_error_handler = block if block_given? @poller_error_handler end |
#queues ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
161 162 163 |
# File 'lib/aws/active_job/sqs/configuration.rb', line 161 def queues @queues end |
#shutdown_timeout ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
161 162 163 |
# File 'lib/aws/active_job/sqs/configuration.rb', line 161 def shutdown_timeout @shutdown_timeout end |
#threads ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
161 162 163 |
# File 'lib/aws/active_job/sqs/configuration.rb', line 161 def threads @threads end |
#visibility_timeout=(value) ⇒ Object (writeonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
166 167 168 |
# File 'lib/aws/active_job/sqs/configuration.rb', line 166 def visibility_timeout=(value) @visibility_timeout = value end |
Instance Method Details
#excluded_deduplication_keys=(keys) ⇒ Object
169 170 171 |
# File 'lib/aws/active_job/sqs/configuration.rb', line 169 def excluded_deduplication_keys=(keys) @excluded_deduplication_keys = keys.map(&:to_s) | ['job_id'] end |
#to_h ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
198 199 200 201 202 203 204 205 206 |
# File 'lib/aws/active_job/sqs/configuration.rb', line 198 def to_h h = {} instance_variables.each do |v| v_sym = v.to_s.delete('@').to_sym val = instance_variable_get(v) h[v_sym] = val end h end |
#to_s ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
193 194 195 |
# File 'lib/aws/active_job/sqs/configuration.rb', line 193 def to_s to_h.to_s end |