Method: InfluxDB2::Client#initialize

Defined in:
lib/influxdb2/client/client.rb

#initialize(url, token, options = nil) ⇒ Client

Instantiate a new InfluxDB client.

Examples:

Instantiate a client.

InfluxDBClient::Client.new(url: 'https://localhost:8086', token: 'my-token')

Parameters:

  • options (Hash) (defaults to: nil)

    The options to be used by the client.

  • url (String)

    InfluxDB URL to connect to (ex. localhost:8086).

  • token (String)

    Access Token used for authenticating/authorizing the InfluxDB request sent by client.

Options Hash (options):

  • :bucket (String)

    the default destination bucket for writes

  • :org (String)

    the default organization bucket for writes

  • :precision (WritePrecision)

    the default precision for the unix timestamps within

  • :open_timeout (Integer)

    Number of seconds to wait for the connection to open

  • :write_timeout (Integer)

    Number of seconds to wait for one block of data to be written

  • :read_timeout (Integer)

    Number of seconds to wait for one block of data to be read

  • :max_redirect_count (Integer)

    Maximal number of followed HTTP redirects

  • :redirect_forward_authorization (bool)

    Pass Authorization header to different domain during HTTP redirect.

  • :use_ssl (bool)

    Turn on/off SSL for HTTP communication

  • :verify_mode (Integer)

    Sets the flags for the certification verification at beginning of SSL/TLS session. Could be one of ‘OpenSSL::SSL::VERIFY_NONE` or `OpenSSL::SSL::VERIFY_PEER`. For more info see - docs.ruby-lang.org/en/3.0.0/Net/HTTP.html#verify_mode.

  • :logger (Logger)

    Logger used for logging. Disable logging by set to false.

  • :debugging (bool)

    Enable debugging for HTTP request/response.

  • :tags (Hash)

    Default tags which will be added to each point written by api.



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/influxdb2/client/client.rb', line 54

def initialize(url, token, options = nil)
  @auto_closeable = []
  @options = options ? options.dup : {}
  @options[:url] = url if url.is_a? String
  @options[:token] = token if token.is_a? String
  @options[:logger] = @options[:logger].nil? ? DefaultApi.create_logger : @options[:logger]
  @options[:debugging] = @options[:debugging].nil? ? false : @options[:debugging]
  @closed = false

  at_exit { close! }
end