Sha256: a55356ebbb7347d2ac47e8adeccd84d9f4ed21712d103cbbd87495ba4b7cd0cb

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

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')

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
legion-transport-1.0.0 lib/legion/transport/settings.rb