Class: Eventboss::Configuration
- Inherits:
-
Object
- Object
- Eventboss::Configuration
- Defined in:
- lib/eventboss/configuration.rb
Constant Summary collapse
- OPTS_ALLOWED_IN_CONFIG_FILE =
%i[ concurrency sns_sqs_name_infix listeners ].freeze
Instance Attribute Summary collapse
- #aws_access_key_id ⇒ Object
- #aws_secret_access_key ⇒ Object
- #aws_sns_endpoint ⇒ Object
- #aws_sqs_endpoint ⇒ Object
- #concurrency ⇒ Object
- #error_handlers ⇒ Object
- #eventboss_account_id ⇒ Object
- #eventboss_app_name ⇒ Object
- #eventboss_region ⇒ Object
- #listeners ⇒ Object
- #log_level ⇒ Object
- #logger ⇒ Object
- #raise_on_missing_configuration ⇒ Object
- #sns_client ⇒ Object
- #sns_sqs_name_infix ⇒ Object
- #sqs_client ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#aws_access_key_id ⇒ Object
91 92 93 |
# File 'lib/eventboss/configuration.rb', line 91 def aws_access_key_id defined_or_default('aws_access_key_id') { ENV['AWS_ACCESS_KEY_ID'] } end |
#aws_secret_access_key ⇒ Object
95 96 97 |
# File 'lib/eventboss/configuration.rb', line 95 def aws_secret_access_key defined_or_default('aws_secret_access_key') { ENV['AWS_SECRET_ACCESS_KEY'] } end |
#aws_sns_endpoint ⇒ Object
103 104 105 |
# File 'lib/eventboss/configuration.rb', line 103 def aws_sns_endpoint defined_or_default('aws_sns_endpoint') { ENV['AWS_SNS_ENDPOINT'] } end |
#aws_sqs_endpoint ⇒ Object
99 100 101 |
# File 'lib/eventboss/configuration.rb', line 99 def aws_sqs_endpoint defined_or_default('aws_sqs_endpoint') { ENV['AWS_SQS_ENDPOINT'] } end |
#concurrency ⇒ Object
41 42 43 44 45 46 |
# File 'lib/eventboss/configuration.rb', line 41 def concurrency defined_or_default('concurrency') do concurrency = ENV['EVENTBOSS_CONCURRENCY'] || ENV['EVENTBUS_CONCURRENCY'] concurrency ? concurrency.to_i : 25 end end |
#error_handlers ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/eventboss/configuration.rb', line 32 def error_handlers defined_or_default('error_handlers') do [ErrorHandlers::Logger.new, ErrorHandlers::NonExistentQueueHandler.new].tap do |handlers| handlers << ErrorHandlers::DbConnectionDropHandler.new if defined?(::ActiveRecord::StatementInvalid) handlers << ErrorHandlers::DbConnectionNotEstablishedHandler.new if defined?(::ActiveRecord::ConnectionNotEstablished) end end end |
#eventboss_account_id ⇒ Object
87 88 89 |
# File 'lib/eventboss/configuration.rb', line 87 def eventboss_account_id defined_or_default('eventboss_account_id') { ENV['EVENTBOSS_ACCOUNT_ID'] || ENV['EVENTBUS_ACCOUNT_ID'] } end |
#eventboss_app_name ⇒ Object
83 84 85 |
# File 'lib/eventboss/configuration.rb', line 83 def eventboss_app_name defined_or_default('eventboss_app_name') { ENV['EVENTBOSS_APP_NAME'] || ENV['EVENTBUS_APP_NAME'] } end |
#eventboss_region ⇒ Object
79 80 81 |
# File 'lib/eventboss/configuration.rb', line 79 def eventboss_region defined_or_default('eventboss_region') { ENV['EVENTBOSS_REGION'] || ENV['EVENTBUS_REGION'] } end |
#listeners ⇒ Object
111 112 113 |
# File 'lib/eventboss/configuration.rb', line 111 def listeners defined_or_default('listeners') { {} } end |
#log_level ⇒ Object
48 49 50 |
# File 'lib/eventboss/configuration.rb', line 48 def log_level defined_or_default('log_level') { :info } end |
#logger ⇒ Object
52 53 54 55 56 |
# File 'lib/eventboss/configuration.rb', line 52 def logger defined_or_default('logger') do ::Logger.new(STDOUT, level: Eventboss.configuration.log_level) end end |
#raise_on_missing_configuration ⇒ Object
28 29 30 |
# File 'lib/eventboss/configuration.rb', line 28 def raise_on_missing_configuration defined_or_default('raise_on_missing_configuration') { (ENV['EVENTBOSS_RAISE_ON_MISSING_CONFIGURATION'] || ENV['EVENTBUS_RAISE_ON_MISSING_CONFIGURATION'])&.downcase == 'true' } end |
#sns_client ⇒ Object
58 59 60 |
# File 'lib/eventboss/configuration.rb', line 58 def sns_client defined_or_default('sns_client') { Eventboss::SnsClient.new(self) } end |
#sns_sqs_name_infix ⇒ Object
107 108 109 |
# File 'lib/eventboss/configuration.rb', line 107 def sns_sqs_name_infix defined_or_default('sns_sqs_name_infix') { ENV['EVENTBOSS_SQS_SNS_NAME_INFIX'] || ENV['EVENTBUS_SQS_SNS_NAME_INFIX'] || 'eventboss' } end |
#sqs_client ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/eventboss/configuration.rb', line 62 def sqs_client defined_or_default('sqs_client') do = { region: eventboss_region, credentials: Aws::Credentials.new( aws_access_key_id, aws_secret_access_key ) } if aws_sqs_endpoint [:endpoint] = aws_sqs_endpoint end Aws::SQS::Client.new() end end |
Instance Method Details
#development_mode? ⇒ Boolean
115 116 117 118 119 |
# File 'lib/eventboss/configuration.rb', line 115 def development_mode? defined_or_default('development_mode') do (ENV['EVENTBOSS_DEVELOPMENT_MODE']&.downcase || ENV['EVENTBUS_DEVELOPMENT_MODE'])&.downcase == 'true' end end |
#server_middleware ⇒ Object
121 122 123 |
# File 'lib/eventboss/configuration.rb', line 121 def server_middleware @server_middleware ||= Middleware::Chain.new end |