Class: Consul::Client::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/consul/client/base.rb

Overview

Public API Base.

Direct Known Subclasses

Agent, Catalog, HealthCheck, KeyValue, Session, Status

Instance Method Summary collapse

Constructor Details

#initialize(options = nil) ⇒ Base

Public: Constructor with options hash

Optional Parameters:

options[:data_center] - The consul data center. Default: 'dc1'.
options[:api_host]    - The api host to request against.  Default: '127.0.0.1'.
options[:api_port]    - The api port the api host is listening to. Default: '8500'.
options[:version]     - The Consul API version to use. Default: 'v1'.
options[:logger]      - The default logging mechanism. Default: Logger.new(STDOUT).

Return: This instance

Raises:

  • (TypeError)


22
23
24
25
26
# File 'lib/consul/client/base.rb', line 22

def initialize(options = nil)
  options = {} if options.nil?
  raise TypeError, 'Options must be nil or a Hash' unless options.is_a?(Hash)
  @options = options.clone
end

Instance Method Details

#is_reachableObject

Public: Test if this Consul Client is reachable.



29
30
31
# File 'lib/consul/client/base.rb', line 29

def is_reachable
  _get(base_url, nil, false) == 'Consul Agent'
end