Method: InfluxDB2::Client.use

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

.use(*args) ⇒ Object

Instantiate a new InfluxDB client with code block. The client will be passed as an argument and will be automatically closed when the block terminates.

It takes same args as #initialize.

Examples:

Instantiate a client.

InfluxDBClient::Client.use(url: 'https://localhost:8086', token: 'my-token') do |client|
  ping = client.ping
  puts ping.version
end


76
77
78
79
80
81
# File 'lib/influxdb2/client/client.rb', line 76

def self.use(*args)
  client = Client.new(*args)
  yield client
ensure
  client.close!
end