Module: Telemetry::Snmp::Data::DefaultOpts

Included in:
Telemetry::Snmp::Data
Defined in:
lib/telemetry/snmp/data/default_opts.rb

Class Method Summary collapse

Class Method Details

.adapterObject



21
22
23
# File 'lib/telemetry/snmp/data/default_opts.rb', line 21

def adapter
  ENV["#{env_key}_adapter"] == 'postgres' ? 'postgres' : 'mysql2'
end

.databaseObject



36
37
38
# File 'lib/telemetry/snmp/data/default_opts.rb', line 36

def database
  ENV["#{env_key}_database"] || 'telemetry_snmp'
end

.default_credentialsObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/telemetry/snmp/data/default_opts.rb', line 5

def default_credentials
  {
    adapter: adapter,
    user: username,
    password: password,
    database: database,
    host: host,
    port: port,
    max_connections: max_connections,
    pool_timeout: pool_timeout,
    preconnect: preconnect,
    test: true
  }
end

.env_keyObject



66
67
68
# File 'lib/telemetry/snmp/data/default_opts.rb', line 66

def env_key
  'telemetry_snmp_data'
end

.hostObject



41
42
43
# File 'lib/telemetry/snmp/data/default_opts.rb', line 41

def host
  ENV["#{env_key}_host"] || '127.0.0.1'
end

.max_connectionsObject



51
52
53
# File 'lib/telemetry/snmp/data/default_opts.rb', line 51

def max_connections
  ENV.key?("#{env_key}_max_connections") ? ENV["#{env_key}_max_connections"].to_i : 16
end

.passwordObject



31
32
33
# File 'lib/telemetry/snmp/data/default_opts.rb', line 31

def password
  ENV["#{env_key}_password"] || nil
end

.pool_timeoutObject



56
57
58
# File 'lib/telemetry/snmp/data/default_opts.rb', line 56

def pool_timeout
  ENV.key?("#{env_key}_pool_timeout") ? ENV["#{env_key}_pool_timeout"].to_i : 2
end

.portObject



46
47
48
# File 'lib/telemetry/snmp/data/default_opts.rb', line 46

def port
  ENV.key?("#{env_key}_port") ? ENV["#{env_key}_port"].to_i : 3306
end

.preconnectObject



61
62
63
# File 'lib/telemetry/snmp/data/default_opts.rb', line 61

def preconnect
  ENV["#{env_key}_preconnect"] || 'concurrently'
end

.usernameObject



26
27
28
# File 'lib/telemetry/snmp/data/default_opts.rb', line 26

def username
  ENV["#{env_key}_username"] || 'root'
end