Class: InfluxDB2::HealthApi Deprecated

Inherits:
DefaultApi show all
Defined in:
lib/influxdb2/client/health_api.rb

Overview

Deprecated.

Use `PingApi` instead

The client of the InfluxDB 2.x that implement Health HTTP API endpoint.

Constant Summary

Constants inherited from DefaultApi

DefaultApi::DEFAULT_REDIRECT_COUNT, DefaultApi::DEFAULT_TIMEOUT, DefaultApi::HEADER_CONTENT_TYPE

Instance Method Summary collapse

Methods inherited from DefaultApi

create_logger, #log

Constructor Details

#initialize(options:) ⇒ HealthApi

Returns a new instance of HealthApi.

Parameters:

  • options (Hash)

    The options to be used by the client.



28
29
30
# File 'lib/influxdb2/client/health_api.rb', line 28

def initialize(options:)
  super(options: options)
end

Instance Method Details

#healthHealthCheck

Get the health of an instance.

Returns:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/influxdb2/client/health_api.rb', line 35

def health
  uri = _parse_uri('/health')
  body = _get(uri).body
  data = JSON.parse("[#{body}]", symbolize_names: true)[0]
  HealthCheck.new.tap do |model|
    model.build_from_hash data
  end
rescue StandardError => e
  HealthCheck.new.tap do |model|
    model.name = 'influxdb'
    model.status = 'fail'
    model.message = e.message
  end
end