Class: InfluxDB::Config
- Inherits:
-
Object
- Object
- InfluxDB::Config
- Defined in:
- lib/influxdb/config.rb
Overview
InfluxDB client configuration
Constant Summary collapse
- AUTH_METHODS =
%w(params basic_auth)
Instance Attribute Summary collapse
-
#async ⇒ Object
readonly
Returns the value of attribute async.
-
#auth_method ⇒ Object
Returns the value of attribute auth_method.
-
#database ⇒ Object
Returns the value of attribute database.
-
#denormalize ⇒ Object
Returns the value of attribute denormalize.
-
#hosts ⇒ Object
Returns the value of attribute hosts.
-
#initial_delay ⇒ Object
Returns the value of attribute initial_delay.
-
#max_delay ⇒ Object
Returns the value of attribute max_delay.
-
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
-
#retry ⇒ Object
Returns the value of attribute retry.
-
#ssl_ca_cert ⇒ Object
Returns the value of attribute ssl_ca_cert.
-
#time_precision ⇒ Object
Returns the value of attribute time_precision.
-
#udp ⇒ Object
readonly
Returns the value of attribute udp.
-
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
-
#username ⇒ Object
Returns the value of attribute username.
-
#verify_ssl ⇒ Object
Returns the value of attribute verify_ssl.
Instance Method Summary collapse
- #async? ⇒ Boolean
-
#initialize(opts = {}) ⇒ Config
constructor
rubocop:disable all.
- #udp? ⇒ Boolean
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
#async ⇒ Object (readonly)
Returns the value of attribute async.
24 25 26 |
# File 'lib/influxdb/config.rb', line 24 def async @async end |
#auth_method ⇒ Object
Returns the value of attribute auth_method.
6 7 8 |
# File 'lib/influxdb/config.rb', line 6 def auth_method @auth_method end |
#database ⇒ Object
Returns the value of attribute database.
6 7 8 |
# File 'lib/influxdb/config.rb', line 6 def database @database end |
#denormalize ⇒ Object
Returns the value of attribute denormalize.
6 7 8 |
# File 'lib/influxdb/config.rb', line 6 def denormalize @denormalize end |
#hosts ⇒ Object
Returns the value of attribute hosts.
6 7 8 |
# File 'lib/influxdb/config.rb', line 6 def hosts @hosts end |
#initial_delay ⇒ Object
Returns the value of attribute initial_delay.
6 7 8 |
# File 'lib/influxdb/config.rb', line 6 def initial_delay @initial_delay end |
#max_delay ⇒ Object
Returns the value of attribute max_delay.
6 7 8 |
# File 'lib/influxdb/config.rb', line 6 def max_delay @max_delay end |
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
6 7 8 |
# File 'lib/influxdb/config.rb', line 6 def open_timeout @open_timeout end |
#password ⇒ Object
Returns the value of attribute password.
6 7 8 |
# File 'lib/influxdb/config.rb', line 6 def password @password end |
#port ⇒ Object
Returns the value of attribute port.
6 7 8 |
# File 'lib/influxdb/config.rb', line 6 def port @port end |
#prefix ⇒ Object
Returns the value of attribute prefix.
6 7 8 |
# File 'lib/influxdb/config.rb', line 6 def prefix @prefix end |
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
6 7 8 |
# File 'lib/influxdb/config.rb', line 6 def read_timeout @read_timeout end |
#retry ⇒ Object
Returns the value of attribute retry.
6 7 8 |
# File 'lib/influxdb/config.rb', line 6 def retry @retry end |
#ssl_ca_cert ⇒ Object
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_precision ⇒ Object
Returns the value of attribute time_precision.
6 7 8 |
# File 'lib/influxdb/config.rb', line 6 def time_precision @time_precision end |
#udp ⇒ Object (readonly)
Returns the value of attribute udp.
24 25 26 |
# File 'lib/influxdb/config.rb', line 24 def udp @udp end |
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
6 7 8 |
# File 'lib/influxdb/config.rb', line 6 def use_ssl @use_ssl end |
#username ⇒ Object
Returns the value of attribute username.
6 7 8 |
# File 'lib/influxdb/config.rb', line 6 def username @username end |
#verify_ssl ⇒ Object
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
62 63 64 |
# File 'lib/influxdb/config.rb', line 62 def async? !!async end |
#udp? ⇒ Boolean
58 59 60 |
# File 'lib/influxdb/config.rb', line 58 def udp? !!udp end |