| 1 | package Etcd::Keys; | ||||||||||||||||||||||||||||
| 2 | 4 | $Etcd::Keys::VERSION = '0.002'; | |||||||||||||||||||||||||||
| 3 | 4 | ▶ | use namespace::sweep; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use Etcd::Response; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use Moo::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use Types::Standard qw(Str); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 4 | requires qw(version_prefix api_exec); | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 4 | has _keys_endpoint => ( is => 'lazy', isa => Str ); | |||||||||||||||||||||||||||
| 16 | sub _build__keys_endpoint { | ||||||||||||||||||||||||||||
| 17 | 5 | ▶ | shift->version_prefix . '/keys'; | ||||||||||||||||||||||||||
|
Subroutine
_build__keys_endpoint: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | sub set { | ||||||||||||||||||||||||||||
| 21 | 2 | ▶ | my ($self, $key, $value, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
set: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 22 | 2 | ▶ | croak 'usage: $etcd->set($key, $value, [%args])' if grep { !defined } ($key, $value); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 2 | Etcd::Response->new_from_http($self->api_exec($self->_keys_endpoint.$key, 'PUT', %args, value => $value)); | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | sub get { | ||||||||||||||||||||||||||||
| 27 | 2 | ▶ | my ($self, $key, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 28 | 2 | ▶ | croak 'usage: $etcd->get($key, [%args])' if !defined $key; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 2 | Etcd::Response->new_from_http($self->api_exec($self->_keys_endpoint.$key, 'GET', %args)); | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | sub delete { | ||||||||||||||||||||||||||||
| 33 | 1 | ▶ | my ($self, $key, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
delete: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 34 | 1 | ▶ | croak 'usage: $etcd->delete($key, [%args])' if !defined $key; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 1 | Etcd::Response->new_from_http($self->api_exec($self->_keys_endpoint.$key, 'DELETE', %args)); | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | sub compare_and_swap { | ||||||||||||||||||||||||||||
| 39 | 0 | ▶ | my ($self, $key, $value, $prev_value, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
compare_and_swap: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | croak 'usage: $etcd->compare_and_swap($key, $value, $prev_value, [%args])' if grep { !defined } ($key, $value, $prev_value); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 0 | $self->set($key, $value, %args, prevValue => $prev_value); | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | sub compare_and_delete { | ||||||||||||||||||||||||||||
| 45 | 0 | ▶ | my ($self, $key, $prev_value, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
compare_and_delete: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 46 | 0 | ▶ | croak 'usage: $etcd->compare_and_delete($key, $prev_value, [%args])' if grep { !defined } ($key, $prev_value); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 0 | $self->delete($key, %args, prevValue => $prev_value); | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | sub create { | ||||||||||||||||||||||||||||
| 51 | 0 | ▶ | my ($self, $key, $value, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
create: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | croak 'usage: $etcd->create($key, $value, [%args])' if grep { !defined } ($key, $value); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 0 | $self->set($key, $value, %args, prevExist => 'false'); | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | sub update { | ||||||||||||||||||||||||||||
| 57 | 0 | ▶ | my ($self, $key, $value, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
update: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 58 | 0 | ▶ | croak 'usage: $etcd->update($key, $value, [%args])' if grep { !defined } ($key, $value); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 0 | $self->set($key, $value, %args, prevExist => 'true'); | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | sub exists { | ||||||||||||||||||||||||||||
| 63 | 1 | ▶ | my ($self, $key, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
exists: called CC=2 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 64 | 1 | ▶ | croak 'usage: $etcd->exists($key, [%args])' if !defined $key; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | try { | ||||||||||||||||||||||||||||
| 66 | 1 | ▶ | $self->get($key, %args); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 67 | 1 | 1; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | catch { | ||||||||||||||||||||||||||||
| 70 | 0 | ▶ | die $_ unless defined blessed $_ && $_->isa('Etcd::Error'); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
Branch: 1 branch
Condition0%0/3
defined builtin::blessed($_) and $_->isa("Etcd::Error")
MC/DC0%0/2
defined builtin::blessed($_) and $_->isa("Etcd::Error")
defined builtin::blessed($_)
$_->isa("Etcd::Error")
Truth table0%0/3
A and B
A= defined builtin::blessed($_)B= $_->isa("Etcd::Error")
| |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | die $_ unless $_->error_code == 100; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 0 | ""; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | 1 | } | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | sub create_dir { | ||||||||||||||||||||||||||||
| 77 | 0 | ▶ | my ($self, $key, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
create_dir: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | croak 'usage: $etcd->create_dir($key, [%args])' if !defined $key; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 0 | Etcd::Response->new_from_http($self->api_exec($self->_keys_endpoint.$key, 'PUT', %args, dir => 'true')); | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | sub delete_dir { | ||||||||||||||||||||||||||||
| 83 | 0 | ▶ | my ($self, $key, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
delete_dir: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 84 | 0 | ▶ | croak 'usage: $etcd->delete_dir($key, [%args])' if !defined $key; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | 0 | $self->delete($key, %args, dir => 'true'); | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | sub create_in_order { | ||||||||||||||||||||||||||||
| 89 | 0 | ▶ | my ($self, $key, $value, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
create_in_order: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 90 | 0 | ▶ | croak 'usage: $etcd->create_in_order($key, $value, [%args])' if grep { !defined } ($key, $value); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | 0 | Etcd::Response->new_from_http($self->api_exec($self->_keys_endpoint.$key, 'POST', %args, value => $value)); | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | sub watch { | ||||||||||||||||||||||||||||
| 95 | 0 | ▶ | my ($self, $key, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
watch: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 96 | 0 | ▶ | croak 'usage: $etcd->watch($key, [%args])' if !defined $key; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | 0 | $self->get($key, %args, wait => 'true'); | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 4 | 1; | |||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | __END__ | ||||||||||||||||||||||||||||