lib/legion/transport/settings.rb in legion-transport-1.1.8 vs lib/legion/transport/settings.rb in legion-transport-1.1.9

- old
+ new

@@ -1,27 +1,26 @@ require 'legion/settings' module Legion module Transport module Settings - # Legion::Settings.merge_settings('transport', default) if Legion::Settings.method_defined? :merge_settings def self.connection { read_timeout: 1, heartbeat: 30, automatically_recover: true, continuation_timeout: 4000, network_recovery_interval: 1, connection_timeout: 1, frame_max: 65_536, - user: 'guest', - password: 'guest', - host: '127.0.0.1', - port: '5672', - vhost: '/', - recovery_attempts: 0, - logger_level: 'info', + user: ENV['transport.connection.user'] || 'guest', + password: ENV['transport.connection.password'] || 'guest', + host: ENV['transport.connection.host'] || '127.0.0.1', + port: ENV['transport.connection.port'] || '5672', + vhost: ENV['transport.connection.vhost'] || '/', + recovery_attempts: 100, + logger_level: ENV['transport.log_level'] || 'info', connected: false }.merge(grab_vault_creds) end def self.grab_vault_creds @@ -32,36 +31,52 @@ { user: lease[:username], password: lease[:password] } rescue StandardError {} end + def self.channel + { + default_worker_pool_size: ENV['transport.channel.default_worker_pool_size'] || 1, + session_worker_pool_size: ENV['transport.channel.session_worker_pool_size'] || 8 + } + end + + def self.queues + { + manual_ack: true, + durable: true, + exclusive: false, + block: false, + auto_delete: false, + arguments: { 'x-max-priority': 255, 'x-overflow': 'reject-publish' } + } + end + + def self.exchanges + { + type: 'topic', + arguments: {}, + auto_delete: false, + durable: true, + internal: false + } + end + def self.default { type: 'rabbitmq', connected: false, - logger_level: 'info', + logger_level: ENV['transport.logger_level'] || 'info', messages: { encrypt: false, ttl: nil, priority: 0 }, - exchanges: { - type: 'topic', - arguments: {}, - auto_delete: false, - durable: true, - internal: false - }, - queues: { - manual_ack: true, - durable: true, - exclusive: false, - block: false, - auto_delete: false, - arguments: { 'x-max-priority': 255, 'x-overflow': 'reject-publish' } - }, - prefetch: 2, - connection: connection + prefetch: ENV['transport.prefetch'].to_i || 2, + exchanges: exchanges, + queues: queues, + connection: connection, + channel: channel } end end end end