Class: InfluxdbSetup::Config
- Inherits:
-
Object
- Object
- InfluxdbSetup::Config
- Defined in:
- lib/influxdb_setup/config.rb
Class Attribute Summary collapse
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
Class Method Summary collapse
Instance Method Summary collapse
- #build_client(database = "", options = {}) ⇒ Object
- #db_name ⇒ Object
- #enabled? ⇒ Boolean
-
#initialize(config: self.class.config, logger: Logger.new(STDOUT)) ⇒ Config
constructor
A new instance of Config.
- #password ⇒ Object
- #retention_policies ⇒ Object
- #username ⇒ Object
Constructor Details
#initialize(config: self.class.config, logger: Logger.new(STDOUT)) ⇒ Config
Returns a new instance of Config.
22 23 24 25 |
# File 'lib/influxdb_setup/config.rb', line 22 def initialize(config: self.class.config, logger: Logger.new(STDOUT)) @config = config @logger = logger end |
Class Attribute Details
.config ⇒ Object
11 12 13 14 |
# File 'lib/influxdb_setup/config.rb', line 11 def self.config config_file = ENV.fetch('INFLUXDB_CONFIG_FILE', 'config/influxdb.yml') @config ||= YAML.load(ERB.new(File.read(config_file)).result)[env] end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
20 21 22 |
# File 'lib/influxdb_setup/config.rb', line 20 def logger @logger end |
Class Method Details
.env ⇒ Object
16 17 18 |
# File 'lib/influxdb_setup/config.rb', line 16 def self.env defined?(Rails) ? Rails.env : ENV.fetch('RAILS_ENV', 'development') end |
Instance Method Details
#build_client(database = "", options = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/influxdb_setup/config.rb', line 47 def build_client(database = "", = {}) InfluxDB::Client.new(database, { username: @config.fetch('username', 'root'), password: @config.fetch('password', 'root'), hosts: @config['hosts'], port: @config.fetch('port', 8086), async: @config.fetch('async', false), use_ssl: @config.fetch('use_ssl', false), retry: false, }.merge()) end |
#db_name ⇒ Object
27 28 29 |
# File 'lib/influxdb_setup/config.rb', line 27 def db_name @config['db_name'] end |
#enabled? ⇒ Boolean
31 32 33 |
# File 'lib/influxdb_setup/config.rb', line 31 def enabled? @config['enabled'] end |
#password ⇒ Object
39 40 41 |
# File 'lib/influxdb_setup/config.rb', line 39 def password @config['password'] end |
#retention_policies ⇒ Object
43 44 45 |
# File 'lib/influxdb_setup/config.rb', line 43 def retention_policies @config['retention_policies'] end |
#username ⇒ Object
35 36 37 |
# File 'lib/influxdb_setup/config.rb', line 35 def username @config['username'] end |