lib/legion/transport/settings.rb in legion-transport-1.0.0 vs lib/legion/transport/settings.rb in legion-transport-1.1.0

- old
+ new

@@ -1,5 +1,7 @@ +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 @@ -12,19 +14,21 @@ connection_timeout: 1, user: 'guest', password: 'guest', host: '127.0.0.1', port: '5672', - vhost: 'legion', + vhost: '/', 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') + return {} unless Legion::Settings[:crypt][:vault][:connected] + + lease = Legion::Crypt.read('rabbitmq/creds/legion', type: nil) + Legion::Logging.debug 'successfully grabbed amqp username from Vault' { user: lease[:username], password: lease[:password] } rescue StandardError {} end @@ -59,6 +63,10 @@ end end end end -Legion::Settings.merge_settings('transport', Legion::Transport::Settings.default) if Legion.const_defined?('Settings') +begin + Legion::Settings.merge_settings('transport', Legion::Transport::Settings.default) if Legion.const_defined?('Settings') +rescue StandardError => e + Legion::Logging.fatal(e.message) if Legion::Logging.method_defined?(:fatal) +end