Class: InfluxDB::Config
- Inherits:
-
Object
- Object
- InfluxDB::Config
- Defined in:
- lib/influxdb/config.rb
Overview
InfluxDB client configuration
Constant Summary collapse
- AUTH_METHODS =
Valid values for the “auth_method” option.
[ "params".freeze, "basic_auth".freeze, "none".freeze, ].freeze
Instance Method Summary collapse
- #async? ⇒ Boolean
- #hosts ⇒ Object
-
#initialize(url: nil, **opts) ⇒ Config
constructor
Creates a new instance.
- #next_host ⇒ Object
- #udp? ⇒ Boolean
Constructor Details
#initialize(url: nil, **opts) ⇒ Config
Creates a new instance. See ‘DEFAULT_CONFIG_OPTIONS` for available config options and their default values.
If you provide a “url” option, either as String (hint: ENV) or as URI instance, you can override the defaults. The precedence for a config value is as follows (first found wins):
-
values given in the options hash
-
values found in URL (if given)
-
default values
73 74 75 76 77 78 79 80 81 |
# File 'lib/influxdb/config.rb', line 73 def initialize(url: nil, **opts) opts = opts_from_url(url).merge(opts) if url DEFAULT_CONFIG_OPTIONS.each do |name, value| set_ivar! name, opts.fetch(name, value) end configure_hosts! opts[:hosts] || opts[:host] || "localhost".freeze end |
Instance Method Details
#async? ⇒ Boolean
87 88 89 |
# File 'lib/influxdb/config.rb', line 87 def async? async != false end |
#hosts ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/influxdb/config.rb', line 97 def hosts Array.new(@hosts_queue.length) do host = @hosts_queue.pop @hosts_queue.push(host) host end end |
#next_host ⇒ Object
91 92 93 94 95 |
# File 'lib/influxdb/config.rb', line 91 def next_host host = @hosts_queue.pop @hosts_queue.push(host) host end |
#udp? ⇒ Boolean
83 84 85 |
# File 'lib/influxdb/config.rb', line 83 def udp? udp != false end |