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, #configuration, #initialize, method_missing, respond_to?, respond_to_missing?, #use_named_parameter

Constructor Details

This class inherits a constructor from Diplomat::RestClient

Instance Method Details

#leader(options = {}) ⇒ OpenStruct

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

Parameters:

  • options (Hash) (defaults to: {})

    options parameter hash

Returns:

  • (OpenStruct)

    the address of the leader


11
12
13
14
# File 'lib/diplomat/status.rb', line 11

def leader(options = {})
  ret = send_get_request(@conn, ['/v1/status/leader'], options)
  JSON.parse(ret.body)
end

#peers(options = {}) ⇒ OpenStruct

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

Parameters:

  • options (Hash) (defaults to: {})

    options parameter hash

Returns:

  • (OpenStruct)

    an array of peers


19
20
21
22
# File 'lib/diplomat/status.rb', line 19

def peers(options = {})
  ret = send_get_request(@conn, ['/v1/status/peers'], options)
  JSON.parse(ret.body)
end