Class: Consul::Client::Status
Instance Method Summary collapse
- #build_url(suffix) ⇒ Object
-
#leader ⇒ Object
Public: This endpoint is used to get the Raft leader for the datacenter in which the agent is running.
-
#peers ⇒ Object
Public: This endpoint retrieves the Raft peers for the datacenter in which the the agent is running.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Consul::Client::Base
Instance Method Details
#build_url(suffix) ⇒ Object
34 35 36 |
# File 'lib/consul/client/status.rb', line 34 def build_url(suffix) "#{base_versioned_url}/status/#{suffix}" end |
#leader ⇒ Object
Public: This endpoint is used to get the Raft leader for the datacenter in which the agent is running
Reference: www.consul.io/docs/agent/http/status.html
Returns: Address, host:port.
14 15 16 17 18 19 |
# File 'lib/consul/client/status.rb', line 14 def leader resp = RestClient.get leader_url return resp.body.slice(1, resp.body.length-2) if resp.code == 200 logger.warn("Unable to get leader. Resp code: #{resp.code} Resp message: #{resp.body}") nil end |
#peers ⇒ Object
Public: This endpoint retrieves the Raft peers for the datacenter in which the the agent is running
Reference: www.consul.io/docs/agent/http/status.html
Returns: List of addresses.
27 28 29 30 31 32 |
# File 'lib/consul/client/status.rb', line 27 def peers resp = RestClient.get peers_url return JSON.parse(resp.body) if resp.code == 200 logger.warn("Unable to get peers. Resp code: #{resp.code} Resp message: #{resp.body}") nil end |