Class: Diplomat::Status

Inherits:
RestClient show all
Defined in:
lib/diplomat/status.rb

Overview

Methods for interacting with the Consul status API endpoints, leader and peers

Instance Method Summary collapse

Methods inherited from RestClient

access_method?, #concat_url, #initialize, method_missing, respond_to?, respond_to_missing?, #use_named_parameter

Constructor Details

This class inherits a constructor from Diplomat::RestClient

Instance Method Details

#leaderOpenStruct

Get the raft leader for the datacenter in which the local consul agent is running

Returns:

  • (OpenStruct)

    the address of the leader



8
9
10
11
12
# File 'lib/diplomat/status.rb', line 8

def leader
  url = ['/v1/status/leader']
  ret = @conn.get concat_url url
  JSON.parse(ret.body)
end

#peersOpenStruct

Get an array of Raft peers for the datacenter in which the agent is running

Returns:

  • (OpenStruct)

    an array of peers



16
17
18
19
20
# File 'lib/diplomat/status.rb', line 16

def peers
  url = ['/v1/status/peers']
  ret = @conn.get concat_url url
  JSON.parse(ret.body)
end