line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Etcd::Keys; |
2
|
|
|
|
|
|
|
$Etcd::Keys::VERSION = '0.004'; |
3
|
4
|
|
|
4
|
|
1838
|
use namespace::autoclean; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
27
|
|
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
1717
|
use Etcd::Response; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
137
|
|
6
|
4
|
|
|
4
|
|
23
|
use Try::Tiny; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
272
|
|
7
|
4
|
|
|
4
|
|
20
|
use Scalar::Util qw(blessed); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
192
|
|
8
|
4
|
|
|
4
|
|
22
|
use Carp qw(croak); |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
201
|
|
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
20
|
use Moo::Role; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
31
|
|
11
|
4
|
|
|
4
|
|
1369
|
use Types::Standard qw(Str); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
18
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
requires qw(version_prefix api_exec); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has _keys_endpoint => ( is => 'lazy', isa => Str ); |
16
|
|
|
|
|
|
|
sub _build__keys_endpoint { |
17
|
5
|
|
|
5
|
|
2055
|
shift->version_prefix . '/keys'; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub set { |
21
|
2
|
|
|
2
|
0
|
10872
|
my ($self, $key, $value, %args) = @_; |
22
|
2
|
50
|
|
|
|
6
|
croak 'usage: $etcd->set($key, $value, [%args])' if grep { !defined } ($key, $value); |
|
4
|
|
|
|
|
14
|
|
23
|
2
|
|
|
|
|
13
|
Etcd::Response->new_from_http($self->api_exec($self->_keys_endpoint.$key, 'PUT', %args, value => $value)); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub get { |
27
|
2
|
|
|
2
|
0
|
1709
|
my ($self, $key, %args) = @_; |
28
|
2
|
50
|
|
|
|
6
|
croak 'usage: $etcd->get($key, [%args])' if !defined $key; |
29
|
2
|
|
|
|
|
10
|
Etcd::Response->new_from_http($self->api_exec($self->_keys_endpoint.$key, 'GET', %args)); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub delete { |
33
|
1
|
|
|
1
|
0
|
6755
|
my ($self, $key, %args) = @_; |
34
|
1
|
50
|
|
|
|
5
|
croak 'usage: $etcd->delete($key, [%args])' if !defined $key; |
35
|
1
|
|
|
|
|
7
|
Etcd::Response->new_from_http($self->api_exec($self->_keys_endpoint.$key, 'DELETE', %args)); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub compare_and_swap { |
39
|
0
|
|
|
0
|
0
|
0
|
my ($self, $key, $value, $prev_value, %args) = @_; |
40
|
0
|
0
|
|
|
|
0
|
croak 'usage: $etcd->compare_and_swap($key, $value, $prev_value, [%args])' if grep { !defined } ($key, $value, $prev_value); |
|
0
|
|
|
|
|
0
|
|
41
|
0
|
|
|
|
|
0
|
$self->set($key, $value, %args, prevValue => $prev_value); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub compare_and_delete { |
45
|
0
|
|
|
0
|
0
|
0
|
my ($self, $key, $prev_value, %args) = @_; |
46
|
0
|
0
|
|
|
|
0
|
croak 'usage: $etcd->compare_and_delete($key, $prev_value, [%args])' if grep { !defined } ($key, $prev_value); |
|
0
|
|
|
|
|
0
|
|
47
|
0
|
|
|
|
|
0
|
$self->delete($key, %args, prevValue => $prev_value); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub create { |
51
|
0
|
|
|
0
|
0
|
0
|
my ($self, $key, $value, %args) = @_; |
52
|
0
|
0
|
|
|
|
0
|
croak 'usage: $etcd->create($key, $value, [%args])' if grep { !defined } ($key, $value); |
|
0
|
|
|
|
|
0
|
|
53
|
0
|
|
|
|
|
0
|
$self->set($key, $value, %args, prevExist => 'false'); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub update { |
57
|
0
|
|
|
0
|
0
|
0
|
my ($self, $key, $value, %args) = @_; |
58
|
0
|
0
|
|
|
|
0
|
croak 'usage: $etcd->update($key, $value, [%args])' if grep { !defined } ($key, $value); |
|
0
|
|
|
|
|
0
|
|
59
|
0
|
|
|
|
|
0
|
$self->set($key, $value, %args, prevExist => 'true'); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub exists { |
63
|
1
|
|
|
1
|
0
|
6282
|
my ($self, $key, %args) = @_; |
64
|
1
|
50
|
|
|
|
4
|
croak 'usage: $etcd->exists($key, [%args])' if !defined $key; |
65
|
|
|
|
|
|
|
try { |
66
|
1
|
|
|
1
|
|
39
|
$self->get($key, %args); |
67
|
1
|
|
|
|
|
134
|
1; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
catch { |
70
|
0
|
0
|
0
|
0
|
|
|
die $_ unless defined blessed $_ && $_->isa('Etcd::Error'); |
71
|
0
|
0
|
|
|
|
|
die $_ unless $_->error_code == 100; |
72
|
0
|
|
|
|
|
|
""; |
73
|
|
|
|
|
|
|
} |
74
|
1
|
|
|
|
|
10
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub create_dir { |
77
|
0
|
|
|
0
|
0
|
|
my ($self, $key, %args) = @_; |
78
|
0
|
0
|
|
|
|
|
croak 'usage: $etcd->create_dir($key, [%args])' if !defined $key; |
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
|
|
|
0
|
0
|
|
my ($self, $key, %args) = @_; |
84
|
0
|
0
|
|
|
|
|
croak 'usage: $etcd->delete_dir($key, [%args])' if !defined $key; |
85
|
0
|
|
|
|
|
|
$self->delete($key, %args, dir => 'true'); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub create_in_order { |
89
|
0
|
|
|
0
|
0
|
|
my ($self, $key, $value, %args) = @_; |
90
|
0
|
0
|
|
|
|
|
croak 'usage: $etcd->create_in_order($key, $value, [%args])' if grep { !defined } ($key, $value); |
|
0
|
|
|
|
|
|
|
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
|
|
|
0
|
0
|
|
my ($self, $key, %args) = @_; |
96
|
0
|
0
|
|
|
|
|
croak 'usage: $etcd->watch($key, [%args])' if !defined $key; |
97
|
0
|
|
|
|
|
|
$self->get($key, %args, wait => 'true'); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__END__ |