Class: Philae::EtcdProbe

Inherits:
Object
  • Object
show all
Defined in:
lib/philae/etcd_probe.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, host, port, read_timeout: 1, cacert: nil, ssl_cert: nil, ssl_key: nil) ⇒ EtcdProbe

Returns a new instance of EtcdProbe.

Parameters:

  • read_timeout (Integer) (defaults to: 1)

    Timeout in second for the HTTP request



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/philae/etcd_probe.rb', line 16

def initialize(name, host, port, read_timeout: 1, cacert: nil, ssl_cert: nil, ssl_key: nil)
  if !cacert.nil?
    raise InvalidSSLConfig, 'cacert' if !File.exist?(cacert)
    raise InvalidSSLConfig, 'ssl_cert' if ssl_cert.nil? || !File.exist?(ssl_cert)
    raise InvalidSSLConfig, 'ssl_key' if ssl_key.nil? || !File.exist?(ssl_key)
  end

  @name = name
  @host = host
  @port = port
  @read_timeout = read_timeout
  @cacert = cacert
  @ssl_cert = ssl_cert
  @ssl_key = ssl_key
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/philae/etcd_probe.rb', line 13

def name
  @name
end

Instance Method Details

#checkObject



32
33
34
35
36
37
38
39
40
# File 'lib/philae/etcd_probe.rb', line 32

def check
  begin
    etcd_client.get '/'
  rescue StandardError => e
    return { healthy: false, comment: "Unable to contact etcd (#{e.message})" }
  end

  return { healthy: true, comment: '' }
end