Class: InfluxDB::Config

Inherits:
Object
  • Object
show all
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

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



75
76
77
78
79
80
81
82
83
# File 'lib/influxdb/config.rb', line 75

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

Returns:

  • (Boolean)


89
90
91
# File 'lib/influxdb/config.rb', line 89

def async?
  async != false
end

#hostsObject



99
100
101
102
103
104
105
# File 'lib/influxdb/config.rb', line 99

def hosts
  Array.new(@hosts_queue.length) do
    host = @hosts_queue.pop
    @hosts_queue.push(host)
    host
  end
end

#next_hostObject



93
94
95
96
97
# File 'lib/influxdb/config.rb', line 93

def next_host
  host = @hosts_queue.pop
  @hosts_queue.push(host)
  host
end

#udp?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/influxdb/config.rb', line 85

def udp?
  udp != false
end