Class: InfluxDB::AsyncQueue::Config
- Inherits:
-
Object
- Object
- InfluxDB::AsyncQueue::Config
- Defined in:
- lib/influxdb/async_queue/config.rb
Constant Summary collapse
- ATTRIBUTES =
{ 'batch_size' => 1000, 'sleep_timeout' => 5, 'influxdb/database' => nil, 'influxdb/username' => 'root', 'influxdb/password' => 'root', 'influxdb/port' => 8086, 'influxdb/precision' => 'ms', 'influxdb/retention_policy' => nil, 'influxdb/hosts' => ['localhost'], 'adapter/name' => 'redis', 'adapter/config' => [{ host: 'localhost', port: 6379, db: 0 }] }.freeze
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(config = {}) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(config = {}) ⇒ Config
Returns a new instance of Config.
27 28 29 30 31 |
# File 'lib/influxdb/async_queue/config.rb', line 27 def initialize(config = {}) @config = Hash[config.map { |k,v| [k.to_s, v] }] @config['adapter'] ||= {} @config['influxdb'] ||= {} end |
Instance Attribute Details
#adapter ⇒ Object
47 48 49 50 51 |
# File 'lib/influxdb/async_queue/config.rb', line 47 def adapter @adapter ||= ::InfluxDB::AsyncQueue::Adapters.const_get(adapter_name.camelize).new( *(adapter_config || []) ) end |
#influxdb_client ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/influxdb/async_queue/config.rb', line 57 def influxdb_client @influxdb_client ||= ::InfluxDB::Client.new( username: influxdb_username, password: influxdb_password, hosts: influxdb_hosts, port: influxdb_port, async: false, retry: true, time_precision: influxdb_precision ) end |
#logger ⇒ Object
53 54 55 |
# File 'lib/influxdb/async_queue/config.rb', line 53 def logger @logger ||= Logger.new($stdout) end |
Class Method Details
.load_from_file!(path) ⇒ Object
21 22 23 24 25 |
# File 'lib/influxdb/async_queue/config.rb', line 21 def self.load_from_file!(path) new( YAML.load(File.open(path)) ) end |