Module: Cyclid::Client::Health

Included in:
Tilapia
Defined in:
lib/cyclid/client/health.rb

Overview

Health-check related methods

Instance Method Summary collapse

Instance Method Details

#health_pingBoolean

Ping the API server.

Returns:

  • (Boolean)

    True if the API server is healthy, false if it is unhealthy.



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cyclid/client/health.rb', line 23

def health_ping
  uri = server_uri('/health/status')

  # We need to do without the API helpers as the health endpoint won't
  # return any data, just an HTTP status
  req = authenticate_request(Net::HTTP::Get.new(uri), uri)
  http = Net::HTTP.new(uri.hostname, uri.port)
  res = http.request(req)

  return res.code == '200'
end