| 1 | package Consul::API::Status; | ||||||||||
| 2 | 9 | $Consul::API::Status::VERSION = '0.027'; | |||||||||
| 3 | 9 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 9 | ▶ | use Moo::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 9 | ▶ | use Types::Standard qw(Str); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 9 | requires qw(_version_prefix _api_exec); | |||||||||
| 9 | |||||||||||
| 10 | 9 | has _status_endpoint => ( is => 'lazy', isa => Str ); | |||||||||
| 11 | 0 | ▶ | sub _build__status_endpoint { | ||||||||
|
Subroutine
_build__status_endpoint: not called CC=1 SCAR=6.9
| |||||||||||
| 12 | 0 | shift->_version_prefix . '/status'; | |||||||||
| 13 | } | ||||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | sub status { | ||||||||
|
Subroutine
status: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 16 | 0 | my $self = shift; | |||||||||
| 17 | 0 | ▶ | $self = Consul->new(@_) unless ref $self; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 0 | return bless \$self, "Consul::API::Status::Impl"; | |||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | package | ||||||||||
| 22 | Consul::API::Status::Impl; # hide from PAUSE | ||||||||||
| 23 | |||||||||||
| 24 | 9 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | 9 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | |||||||||||
| 28 | 0 | ▶ | sub leader { | ||||||||
|
Subroutine
leader: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 29 | 0 | my ($self, %args) = @_; | |||||||||
| 30 | 0 | $$self->_api_exec($$self->_status_endpoint."/leader", "GET", %args); | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 0 | ▶ | sub peers { | ||||||||
|
Subroutine
peers: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 34 | 0 | my ($self, %args) = @_; | |||||||||
| 35 | 0 | $$self->_api_exec($$self->_status_endpoint."/peers", "GET", %args); | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 9 | 1; | |||||||||
| 39 | |||||||||||
| 40 | =pod | ||||||||||
| 41 | |||||||||||
| 42 | =encoding UTF-8 | ||||||||||
| 43 | |||||||||||
| 44 | =head1 NAME | ||||||||||
| 45 | |||||||||||
| 46 | Consul::API::Status - System status API | ||||||||||
| 47 | |||||||||||
| 48 | =head1 SYNOPSIS | ||||||||||
| 49 | |||||||||||
| 50 | use Consul; | ||||||||||
| 51 | my $status = Consul->status; | ||||||||||
| 52 | my $peers = $status->peers; | ||||||||||
| 53 | say "@$peers"; | ||||||||||
| 54 | |||||||||||
| 55 | =head1 DESCRIPTION | ||||||||||
| 56 | |||||||||||
| 57 | The system status API is used to get information about the status of the Consul | ||||||||||
| 58 | cluster. | ||||||||||
| 59 | |||||||||||
| 60 | This API is fully documented at L<https://www.consul.io/docs/agent/http/status.html>. | ||||||||||
| 61 | |||||||||||
| 62 | =head1 METHODS | ||||||||||
| 63 | |||||||||||
| 64 | =head2 leader | ||||||||||
| 65 | |||||||||||
| 66 | $status->leader; | ||||||||||
| 67 | |||||||||||
| 68 | Returns the address of the Raft leader for the datacenter in which the agent is | ||||||||||
| 69 | running. Returns an IP:port string. | ||||||||||
| 70 | |||||||||||
| 71 | =head2 peers | ||||||||||
| 72 | |||||||||||
| 73 | $status->peers; | ||||||||||
| 74 | |||||||||||
| 75 | Retrieves the Raft peers for the datacenter in which the agent is running. | ||||||||||
| 76 | Returns an arrayref of IP:port strings. | ||||||||||
| 77 | |||||||||||
| 78 | =head1 SEE ALSO | ||||||||||
| 79 | |||||||||||
| 80 | L<Consul> | ||||||||||
| 81 | |||||||||||
| 82 | =cut | ||||||||||