Class: InfluxDB::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/influxdb/config.rb

Overview

InfluxDB client configuration

Constant Summary collapse

AUTH_METHODS =
%w(params basic_auth)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Config

rubocop:disable all



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/influxdb/config.rb', line 27

def initialize(opts = {})
  @database = opts[:database]
  @hosts = Array(opts[:hosts] || opts[:host] || ["localhost"])
  @port = opts.fetch(:port, 8086)
  @prefix = opts.fetch(:prefix, '')
  @username = opts.fetch(:username, "root")
  @password = opts.fetch(:password, "root")
  @auth_method = AUTH_METHODS.include?(opts[:auth_method]) ? opts[:auth_method] : "params"
  @use_ssl = opts.fetch(:use_ssl, false)
  @verify_ssl = opts.fetch(:verify_ssl, true)
  @ssl_ca_cert = opts.fetch(:ssl_ca_cert, false)
  @time_precision = opts.fetch(:time_precision, "s")
  @initial_delay = opts.fetch(:initial_delay, 0.01)
  @max_delay = opts.fetch(:max_delay, 30)
  @open_timeout = opts.fetch(:write_timeout, 5)
  @read_timeout = opts.fetch(:read_timeout, 300)
  @async = opts.fetch(:async, false)
  @udp = opts.fetch(:udp, false)
  @retry = opts.fetch(:retry, nil)
  @denormalize = opts.fetch(:denormalize, true)
  @retry =
    case @retry
    when Integer
      @retry
    when true, nil
      -1
    when false
      0
    end
end

Instance Attribute Details

#asyncObject (readonly)

Returns the value of attribute async.



24
25
26
# File 'lib/influxdb/config.rb', line 24

def async
  @async
end

#auth_methodObject

Returns the value of attribute auth_method.



6
7
8
# File 'lib/influxdb/config.rb', line 6

def auth_method
  @auth_method
end

#databaseObject

Returns the value of attribute database.



6
7
8
# File 'lib/influxdb/config.rb', line 6

def database
  @database
end

#denormalizeObject

Returns the value of attribute denormalize.



6
7
8
# File 'lib/influxdb/config.rb', line 6

def denormalize
  @denormalize
end

#hostsObject

Returns the value of attribute hosts.



6
7
8
# File 'lib/influxdb/config.rb', line 6

def hosts
  @hosts
end

#initial_delayObject

Returns the value of attribute initial_delay.



6
7
8
# File 'lib/influxdb/config.rb', line 6

def initial_delay
  @initial_delay
end

#max_delayObject

Returns the value of attribute max_delay.



6
7
8
# File 'lib/influxdb/config.rb', line 6

def max_delay
  @max_delay
end

#open_timeoutObject

Returns the value of attribute open_timeout.



6
7
8
# File 'lib/influxdb/config.rb', line 6

def open_timeout
  @open_timeout
end

#passwordObject

Returns the value of attribute password.



6
7
8
# File 'lib/influxdb/config.rb', line 6

def password
  @password
end

#portObject

Returns the value of attribute port.



6
7
8
# File 'lib/influxdb/config.rb', line 6

def port
  @port
end

#prefixObject

Returns the value of attribute prefix.



6
7
8
# File 'lib/influxdb/config.rb', line 6

def prefix
  @prefix
end

#read_timeoutObject

Returns the value of attribute read_timeout.



6
7
8
# File 'lib/influxdb/config.rb', line 6

def read_timeout
  @read_timeout
end

#retryObject

Returns the value of attribute retry.



6
7
8
# File 'lib/influxdb/config.rb', line 6

def retry
  @retry
end

#ssl_ca_certObject

Returns the value of attribute ssl_ca_cert.



6
7
8
# File 'lib/influxdb/config.rb', line 6

def ssl_ca_cert
  @ssl_ca_cert
end

#time_precisionObject

Returns the value of attribute time_precision.



6
7
8
# File 'lib/influxdb/config.rb', line 6

def time_precision
  @time_precision
end

#udpObject (readonly)

Returns the value of attribute udp.



24
25
26
# File 'lib/influxdb/config.rb', line 24

def udp
  @udp
end

#use_sslObject

Returns the value of attribute use_ssl.



6
7
8
# File 'lib/influxdb/config.rb', line 6

def use_ssl
  @use_ssl
end

#usernameObject

Returns the value of attribute username.



6
7
8
# File 'lib/influxdb/config.rb', line 6

def username
  @username
end

#verify_sslObject

Returns the value of attribute verify_ssl.



6
7
8
# File 'lib/influxdb/config.rb', line 6

def verify_ssl
  @verify_ssl
end

Instance Method Details

#async?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/influxdb/config.rb', line 62

def async?
  !!async
end

#udp?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/influxdb/config.rb', line 58

def udp?
  !!udp
end