AnyEvent-KVStore-Etcd

 view release on metacpan or  search on metacpan

lib/AnyEvent/KVStore/Etcd.pm  view on Meta::CPAN

has host => (is => 'ro', isa => Str, default => sub { 'localhost' });

=head2 port Int

Port for connection.  It defaults to 2379.

=cut

has port => (is => 'ro', isa => Int, default => sub { 2379 } );

=head2 ssl Bool default false

whether to use SSL or not.  The default is no.

=cut

has ssl => (is => 'ro', isa => Bool, default => 0);

=head2 user Str

Username for authentication.  Does not authenticate if not set.

=cut

has user => (is => 'ro', isa => Str);

=head2 password Str

lib/AnyEvent/KVStore/Etcd.pm  view on Meta::CPAN

# This relies on the fact that Moo(se) objects are blessed hashrefs.

sub _slice {
    my $self = shift;
    my @vars = @_;
    return { %{$self}{@vars} };
}

sub _etcd_connect {
    my $self = shift;
    my $cnx = Net::Etcd->new($self->_slice('host', 'port', 'ssl'));
    die 'Could not create new etcd connection' unless $cnx;
    $cnx->auth($self->_slice('user', 'password'))->authenticate if $self->user;
    return $cnx;
}


has cnx => (is => 'ro', builder => '_etcd_connect', lazy => 1);

=head1 METHODS



( run in 0.994 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )