Module: Telemetry::Snmp::Data::DefaultOpts
- Included in:
- Telemetry::Snmp::Data
- Defined in:
- lib/telemetry/snmp/data/default_opts.rb
Class Method Summary collapse
- .adapter ⇒ Object
- .database ⇒ Object
- .default_credentials ⇒ Object
- .env_key ⇒ Object
- .host ⇒ Object
- .max_connections ⇒ Object
- .password ⇒ Object
- .pool_timeout ⇒ Object
- .port ⇒ Object
- .preconnect ⇒ Object
- .username ⇒ Object
Class Method Details
.adapter ⇒ Object
21 22 23 |
# File 'lib/telemetry/snmp/data/default_opts.rb', line 21 def adapter ENV["#{env_key}_adapter"] == 'postgres' ? 'postgres' : 'mysql2' end |
.database ⇒ Object
36 37 38 |
# File 'lib/telemetry/snmp/data/default_opts.rb', line 36 def database ENV["#{env_key}_database"] || 'telemetry_snmp' end |
.default_credentials ⇒ Object
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_key ⇒ Object
66 67 68 |
# File 'lib/telemetry/snmp/data/default_opts.rb', line 66 def env_key 'telemetry_snmp_data' end |
.host ⇒ Object
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_connections ⇒ Object
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 |
.password ⇒ Object
31 32 33 |
# File 'lib/telemetry/snmp/data/default_opts.rb', line 31 def password ENV["#{env_key}_password"] || nil end |
.pool_timeout ⇒ Object
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 |
.port ⇒ Object
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 |
.preconnect ⇒ Object
61 62 63 |
# File 'lib/telemetry/snmp/data/default_opts.rb', line 61 def preconnect ENV["#{env_key}_preconnect"] || 'concurrently' end |
.username ⇒ Object
26 27 28 |
# File 'lib/telemetry/snmp/data/default_opts.rb', line 26 def username ENV["#{env_key}_username"] || 'root' end |