Module: Legion::Transport::Settings

Defined in:
lib/legion/transport/settings.rb

Class Method Summary collapse

Class Method Details

.connectionObject

Legion::Settings.merge_settings(‘transport’, default) if Legion::Settings.method_defined? :merge_settings



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/legion/transport/settings.rb', line 7

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

.defaultObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/legion/transport/settings.rb', line 35

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

.grab_vault_credsObject



25
26
27
28
29
30
31
32
33
# File 'lib/legion/transport/settings.rb', line 25

def self.grab_vault_creds
  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