lib/legion/transport/settings.rb in legion-transport-1.1.9 vs lib/legion/transport/settings.rb in legion-transport-1.2.0
- old
+ new
@@ -24,14 +24,16 @@
end
def self.grab_vault_creds
return {} unless Legion::Settings[:crypt][:vault][:connected]
+ Legion::Transport.logger.info 'Attempting to grab RabbitMQ creds from vault'
lease = Legion::Crypt.read('rabbitmq/creds/legion', type: nil)
- Legion::Logging.debug 'successfully grabbed amqp username from Vault'
+ Legion::Transport.logger.debug 'successfully grabbed amqp username from Vault'
{ user: lease[:username], password: lease[:password] }
rescue StandardError
+ Legion::Transport.logger.warn 'Error reading rabbitmq creds from vault'
{}
end
def self.channel
{
@@ -59,20 +61,25 @@
durable: true,
internal: false
}
end
+ def self.messages
+ {
+ encrypt: ENV['transport.messsages.encrypt'] == 'true',
+ ttl: ENV['transport.messages.ttl'],
+ priority: ENV['transport.messages.priority'].to_i || 0,
+ persistent: ENV['transport.messages.persistent'] == 'true'
+ }
+ end
+
def self.default
{
type: 'rabbitmq',
connected: false,
logger_level: ENV['transport.logger_level'] || 'info',
- messages: {
- encrypt: false,
- ttl: nil,
- priority: 0
- },
+ messages: messages,
prefetch: ENV['transport.prefetch'].to_i || 2,
exchanges: exchanges,
queues: queues,
connection: connection,
channel: channel
@@ -82,8 +89,8 @@
end
end
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)
+rescue StandardError
+ Legion::Transport.logger.fatal(e.message)
end