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: 1, automatically_recover: true, continuation_timeout: 4000, network_recovery_interval: 1, connection_timeout: 1, user: 'guest', password: 'guest', host: '127.0.0.1', port: '5672', vhost: 'legion', recovery_attempts: 0, logger_level: 'info' }.merge(grab_vault_creds) end def self.grab_vault_creds {} unless Legion::Settings[:vault][:connected] lease = Legion::Crypt.read('rabbitmq/creds/legion') { user: lease[:username], password: lease[:password] } rescue StandardError {} end def self.default { type: 'rabbitmq', connected: false, 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 } end end end end Legion::Settings.merge_settings('transport', Legion::Transport::Settings.default) if Legion.const_defined?('Settings')