line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
9
|
|
|
9
|
|
4469
|
use utf8; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
53
|
|
2
|
|
|
|
|
|
|
package Net::Etcd::KV; |
3
|
|
|
|
|
|
|
|
4
|
9
|
|
|
9
|
|
364
|
use strict; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
182
|
|
5
|
9
|
|
|
9
|
|
66
|
use warnings; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
216
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=encoding utf8 |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=cut |
10
|
9
|
|
|
9
|
|
39
|
use Moo::Role; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
55
|
|
11
|
9
|
|
|
9
|
|
3117
|
use Types::Standard qw(Str Int Bool HashRef ArrayRef); |
|
9
|
|
|
|
|
37
|
|
|
9
|
|
|
|
|
79
|
|
12
|
9
|
|
|
9
|
|
11498
|
use Net::Etcd::KV::Put; |
|
9
|
|
|
|
|
28
|
|
|
9
|
|
|
|
|
290
|
|
13
|
9
|
|
|
9
|
|
3825
|
use Net::Etcd::KV::Range; |
|
9
|
|
|
|
|
31
|
|
|
9
|
|
|
|
|
329
|
|
14
|
9
|
|
|
9
|
|
3688
|
use Net::Etcd::KV::DeleteRange; |
|
9
|
|
|
|
|
26
|
|
|
9
|
|
|
|
|
275
|
|
15
|
9
|
|
|
9
|
|
3695
|
use Net::Etcd::KV::Txn; |
|
9
|
|
|
|
|
29
|
|
|
9
|
|
|
|
|
286
|
|
16
|
9
|
|
|
9
|
|
3429
|
use Net::Etcd::KV::Op; |
|
9
|
|
|
|
|
27
|
|
|
9
|
|
|
|
|
288
|
|
17
|
9
|
|
|
9
|
|
3489
|
use Net::Etcd::KV::Compare; |
|
9
|
|
|
|
|
25
|
|
|
9
|
|
|
|
|
337
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
with 'Net::Etcd::Role::Actions'; |
20
|
9
|
|
|
9
|
|
59
|
use namespace::clean; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
33
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 NAME |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Net::Etcd::KV |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $VERSION = '0.020'; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Key Value role providing easy access to Put and Range classes |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 PUBLIC METHODS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 range |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Range gets the keys in the range from the key-value store. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# get range |
43
|
|
|
|
|
|
|
$etcd->range({key =>'test0', range_end => 'test100'}) |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub range { |
48
|
0
|
|
|
0
|
1
|
|
my ( $self, $options ) = @_; |
49
|
0
|
0
|
|
|
|
|
my $cb = pop if ref $_[-1] eq 'CODE'; |
50
|
0
|
0
|
|
|
|
|
my $range = Net::Etcd::KV::Range->new( |
51
|
|
|
|
|
|
|
endpoint => '/kv/range', |
52
|
|
|
|
|
|
|
etcd => $self, |
53
|
|
|
|
|
|
|
cb => $cb, |
54
|
|
|
|
|
|
|
( $options ? %$options : () ), |
55
|
|
|
|
|
|
|
); |
56
|
0
|
0
|
|
|
|
|
$range->request unless $range->hold; |
57
|
0
|
|
|
|
|
|
return $range |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 deleterange |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
DeleteRange deletes the given range from the key-value store. A delete |
63
|
|
|
|
|
|
|
request increments the revision of the key-value store and generates a |
64
|
|
|
|
|
|
|
delete event in the event history for every deleted key. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
$etcd->deleterange({key => 'test0'}) |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub deleterange { |
71
|
0
|
|
|
0
|
1
|
|
my ( $self, $options ) = @_; |
72
|
0
|
0
|
|
|
|
|
my $cb = pop if ref $_[-1] eq 'CODE'; |
73
|
0
|
0
|
|
|
|
|
my $delete_range = Net::Etcd::KV::DeleteRange->new( |
74
|
|
|
|
|
|
|
endpoint => '/kv/deleterange', |
75
|
|
|
|
|
|
|
etcd => $self, |
76
|
|
|
|
|
|
|
cb => $cb, |
77
|
|
|
|
|
|
|
( $options ? %$options : () ), |
78
|
|
|
|
|
|
|
); |
79
|
0
|
0
|
|
|
|
|
$delete_range->request unless $delete_range->hold; |
80
|
0
|
|
|
|
|
|
return $delete_range; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 put |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Put puts the given key into the key-value store. A put request increments |
86
|
|
|
|
|
|
|
the revision of the key-value store and generates one event in the event |
87
|
|
|
|
|
|
|
history. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
$etcd->put({key =>'test0', value=> 'bar'}) |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub put { |
94
|
0
|
|
|
0
|
1
|
|
my ( $self, $options ) = @_; |
95
|
0
|
0
|
|
|
|
|
my $cb = pop if ref $_[-1] eq 'CODE'; |
96
|
0
|
0
|
|
|
|
|
my $put = Net::Etcd::KV::Put->new( |
97
|
|
|
|
|
|
|
endpoint => '/kv/put', |
98
|
|
|
|
|
|
|
etcd => $self, |
99
|
|
|
|
|
|
|
cb => $cb, |
100
|
|
|
|
|
|
|
( $options ? %$options : () ), |
101
|
|
|
|
|
|
|
); |
102
|
0
|
0
|
|
|
|
|
$put->request unless $put->hold; |
103
|
0
|
|
|
|
|
|
return $put; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 txn |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Txn processes multiple requests in a single transaction. A txn request increments |
109
|
|
|
|
|
|
|
the revision of the key-value store and generates events with the same revision for |
110
|
|
|
|
|
|
|
every completed request. It is not allowed to modify the same key several times |
111
|
|
|
|
|
|
|
within one txn. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub txn { |
116
|
0
|
|
|
0
|
1
|
|
my ( $self, $options ) = @_; |
117
|
0
|
0
|
|
|
|
|
my $cb = pop if ref $_[-1] eq 'CODE'; |
118
|
0
|
0
|
|
|
|
|
my $txn = Net::Etcd::KV::Txn->new( |
119
|
|
|
|
|
|
|
%$self, |
120
|
|
|
|
|
|
|
endpoint => '/kv/txn', |
121
|
|
|
|
|
|
|
etcd => $self, |
122
|
|
|
|
|
|
|
cb => $cb, |
123
|
|
|
|
|
|
|
( $options ? %$options : () ), |
124
|
|
|
|
|
|
|
); |
125
|
0
|
|
|
|
|
|
return $txn->create; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 op |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub op { |
133
|
0
|
|
|
0
|
1
|
|
my ( $self, $options ) = @_; |
134
|
0
|
0
|
|
|
|
|
my $cb = pop if ref $_[-1] eq 'CODE'; |
135
|
0
|
0
|
|
|
|
|
my $op = Net::Etcd::KV::Op->new( |
136
|
|
|
|
|
|
|
%$self, |
137
|
|
|
|
|
|
|
( $options ? %$options : () ), |
138
|
|
|
|
|
|
|
); |
139
|
0
|
|
|
|
|
|
return $op->create; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 compare |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub compare { |
147
|
0
|
|
|
0
|
1
|
|
my ( $self, $options ) = @_; |
148
|
0
|
0
|
|
|
|
|
my $cb = pop if ref $_[-1] eq 'CODE'; |
149
|
0
|
0
|
|
|
|
|
my $cmp = Net::Etcd::KV::Compare->new( |
150
|
|
|
|
|
|
|
%$self, |
151
|
|
|
|
|
|
|
( $options ? %$options : () ), |
152
|
|
|
|
|
|
|
); |
153
|
0
|
|
|
|
|
|
return $cmp->json_args; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
1; |