Consul

 view release on metacpan or  search on metacpan

lib/Consul.pm  view on Meta::CPAN


use Moo;
use Types::Standard qw(Str CodeRef HashRef);
use Type::Utils qw(class_type);

has method   => ( is => 'ro', isa => Str,                            required => 1 );
has url      => ( is => 'ro', isa => Str,                            required => 1 );
has headers  => ( is => 'ro', isa => class_type('Hash::MultiValue'), required => 1 );
has content  => ( is => 'ro', isa => Str,                            required => 1 );
has callback => ( is => 'ro', isa => CodeRef,                        required => 1 );
has args     => ( is => 'ro', isa => HashRef,                        required => 1 );


package
    Consul::Response; # hide from PAUSE

use Moo;
use Types::Standard qw(Str Int);
use Type::Utils qw(class_type);

has status   => ( is => 'ro', isa => Int,                            required => 1 );

lib/Consul/API/Agent.pm  view on Meta::CPAN


package Consul::API::Agent::Service;
$Consul::API::Agent::Service::VERSION = '0.027';
use Moo;
use Types::Standard qw(Str Int ArrayRef);

has id      => ( is => 'ro', isa => Str,           init_arg => 'ID',      required => 1 );
has service => ( is => 'ro', isa => Str,           init_arg => 'Service', required => 1 );
has address => ( is => 'ro', isa => Str,           init_arg => 'Address', required => 1 );
has port    => ( is => 'ro', isa => Int,           init_arg => 'Port',    required => 1 );
has tags    => ( is => 'ro', isa => ArrayRef[Str], init_arg => 'Tags',    required => 1, coerce => sub { $_[0] || [] } );

package Consul::API::Agent::Member;
$Consul::API::Agent::Member::VERSION = '0.027';
use Moo;
use Types::Standard qw(Str Int HashRef);

has name         => ( is => 'ro', isa => Str,          init_arg => 'Name',        required => 1 );
has addr         => ( is => 'ro', isa => Str,          init_arg => 'Addr',        required => 1 );
has port         => ( is => 'ro', isa => Int,          init_arg => 'Port',        required => 1 );
has tags         => ( is => 'ro', isa => HashRef[Str], init_arg => 'Tags',        required => 1, coerce => sub { $_[0] || {} } );
has status       => ( is => 'ro', isa => Int,          init_arg => 'Status',      required => 1 );
has protocol_min => ( is => 'ro', isa => Int,          init_arg => 'ProtocolMin', required => 1 );
has protocol_max => ( is => 'ro', isa => Int,          init_arg => 'ProtocolMax', required => 1 );
has protocol_cur => ( is => 'ro', isa => Int,          init_arg => 'ProtocolCur', required => 1 );
has delegate_min => ( is => 'ro', isa => Int,          init_arg => 'DelegateMin', required => 1 );
has delegate_max => ( is => 'ro', isa => Int,          init_arg => 'DelegateMax', required => 1 );
has delegate_cur => ( is => 'ro', isa => Int,          init_arg => 'DelegateCur', required => 1 );

package Consul::API::Agent::Self;
$Consul::API::Agent::Self::VERSION = '0.027';
use Moo;
use Types::Standard qw(HashRef);
use Type::Utils qw(class_type);

# XXX raw hash. not happy about this, but the list of config keys don't seem to be consistent across environments
has config => ( is => 'ro', isa => HashRef,                                  init_arg => 'Config', required => 1, coerce => sub { $_[0] || {} } );
has member => ( is => 'ro', isa => class_type('Consul::API::Agent::Member'), init_arg => 'Member', required => 1, coerce => sub { Consul::API::Agent::Member->new($_[0]) } );

1;

=pod

=encoding UTF-8

=head1 NAME

lib/Consul/API/Catalog.pm  view on Meta::CPAN

$Consul::API::Catalog::Service::VERSION = '0.027';
use Moo;
use Types::Standard qw(Str Int ArrayRef);

has name            => ( is => 'ro', isa => Str,           init_arg => 'ServiceName',    required => 1 );
has id              => ( is => 'ro', isa => Str,           init_arg => 'ServiceID',      required => 1 );
has service_address => ( is => 'ro', isa => Str,           init_arg => 'ServiceAddress', required => 1 );
has port            => ( is => 'ro', isa => Int,           init_arg => 'ServicePort',    required => 1 );
has node            => ( is => 'ro', isa => Str,           init_arg => 'Node',           required => 1 );
has address         => ( is => 'ro', isa => Str,           init_arg => 'Address',        required => 1 );
has tags            => ( is => 'ro', isa => ArrayRef[Str], init_arg => 'ServiceTags',    required => 1, coerce => sub { $_[0] || [] } );

package Consul::API::Catalog::Node;
$Consul::API::Catalog::Node::VERSION = '0.027';
use Moo;
use Types::Standard qw(HashRef);
use Type::Utils qw(class_type);

has node     => ( is => 'ro', isa => class_type('Consul::API::Catalog::ShortNode'),      init_arg => 'Node',     required => 1, coerce => sub { Consul::API::Catalog::ShortNode->new($_[0]) } );
has services => ( is => 'ro', isa => HashRef[class_type('Consul::API::Agent::Service')], init_arg => 'Services', required => 1, coerce => sub { +{ map { $_ => Consul::API::Agent::Service->new($_[0]->{$_}) } keys %{$_[0]} } } );

1;

=pod

=encoding UTF-8

=head1 NAME

Consul::API::Catalog - Catalog (nodes and services) API

lib/Consul/API/Health.pm  view on Meta::CPAN

has service_name => ( is => 'ro', isa => Str, init_arg => 'ServiceName', required => 1 );

package Consul::API::Health::Service;
$Consul::API::Health::Service::VERSION = '0.027';
use Moo;
use Types::Standard qw(ArrayRef);
use Type::Utils qw(class_type);

has node    => ( is => 'ro', isa => class_type('Consul::API::Catalog::ShortNode'),      init_arg => 'Node',    required => 1, coerce => sub { Consul::API::Catalog::ShortNode->new($_[0]) } );
has service => ( is => 'ro', isa => class_type('Consul::API::Agent::Service'),          init_arg => 'Service', required => 1, coerce => sub { Consul::API::Agent::Service->new($_[0]) } );
has checks  => ( is => 'ro', isa => ArrayRef[class_type('Consul::API::Health::Check')], init_arg => 'Checks',  required => 1, coerce => sub { [ map { Consul::API::Health::Check->new($_) } @{$_[0]} ] } );

1;

=pod

=encoding UTF-8

=head1 NAME

Consul::API::Health - Health check API

lib/Consul/API/Session.pm  view on Meta::CPAN

package Consul::API::Session::Session;
$Consul::API::Session::Session::VERSION = '0.027';
use Moo;
use Types::Standard qw(Str Enum ArrayRef Num Int);

has id           => ( is => 'ro', isa => Str,                      init_arg => 'ID',          required => 1 );
has name         => ( is => 'ro', isa => Str,                      init_arg => 'Name',        required => 1 );
has behavior     => ( is => 'ro', isa => Enum[qw(release delete)], init_arg => 'Behavior',    required => 1 );
has ttl          => ( is => 'ro', isa => Str,                      init_arg => 'TTL',         required => 1 );
has node         => ( is => 'ro', isa => Str,                      init_arg => 'Node',        required => 1 );
has checks       => ( is => 'ro', isa => ArrayRef[Str],            init_arg => 'Checks',                    );
has lock_delay   => ( is => 'ro', isa => Num,                      init_arg => 'LockDelay',   required => 1 );
has create_index => ( is => 'ro', isa => Int,                      init_arg => 'CreateIndex', required => 1 );

1;

=pod

=encoding UTF-8

=head1 NAME

lib/Consul/Service.pm  view on Meta::CPAN


use Moo;
use Types::Standard qw(Str Int Bool ArrayRef);
use Carp qw(croak);
use JSON::MaybeXS;

has name                => ( is => 'ro', isa => Str,           required => 1 );
has id                  => ( is => 'ro', isa => Str );
has address             => ( is => 'ro', isa => Str );
has port                => ( is => 'ro', isa => Int );
has tags                => ( is => 'ro', isa => ArrayRef[Str], default => sub { [] } );
has script              => ( is => 'ro', isa => Str );
has interval            => ( is => 'ro', isa => Str );
has ttl                 => ( is => 'ro', isa => Str );
has enable_tag_override => ( is => 'ro', isa => Bool,          default => sub { 0 } );

sub BUILD {
    my ($self) = @_;

    my $A = defined $self->script;
    my $B = defined $self->interval;

lib/Consul/Session.pm  view on Meta::CPAN


use Moo;
use Types::Standard qw(Str ArrayRef Enum);
use Carp qw(croak);
use JSON::MaybeXS;

has name       => ( is => 'ro', isa => Str );
has behavior   => ( is => 'ro', isa => Enum[qw(release delete)] );
has ttl        => ( is => 'ro', isa => Str );
has node       => ( is => 'ro', isa => Str );
has checks     => ( is => 'ro', isa => ArrayRef[Str] );
has lock_delay => ( is => 'ro', isa => Str );

sub to_json { shift->_json }
has _json => ( is => 'lazy', isa => Str );
sub _build__json {
    my ($self) = @_;
    encode_json({
        defined $self->lock_delay ? ( LockDelay => $self->lock_delay ) : (),
        defined $self->node       ? ( Node      => $self->node )       : (),
        defined $self->name       ? ( Name      => $self->name )       : (),



( run in 0.622 second using v1.01-cache-2.11-cpan-5f2e87ce722 )