line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
9
|
|
|
9
|
|
3530
|
use utf8; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
39
|
|
2
|
|
|
|
|
|
|
package Net::Etcd::KV; |
3
|
|
|
|
|
|
|
|
4
|
9
|
|
|
9
|
|
292
|
use strict; |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
142
|
|
5
|
9
|
|
|
9
|
|
36
|
use warnings; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
167
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=encoding utf8 |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=cut |
10
|
9
|
|
|
9
|
|
41
|
use Moo::Role; |
|
9
|
|
|
|
|
13
|
|
|
9
|
|
|
|
|
64
|
|
11
|
9
|
|
|
9
|
|
2733
|
use Types::Standard qw(Str Int Bool HashRef ArrayRef); |
|
9
|
|
|
|
|
23
|
|
|
9
|
|
|
|
|
44
|
|
12
|
9
|
|
|
9
|
|
9272
|
use Net::Etcd::KV::Put; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
214
|
|
13
|
9
|
|
|
9
|
|
2935
|
use Net::Etcd::KV::Range; |
|
9
|
|
|
|
|
24
|
|
|
9
|
|
|
|
|
262
|
|
14
|
9
|
|
|
9
|
|
3085
|
use Net::Etcd::KV::DeleteRange; |
|
9
|
|
|
|
|
24
|
|
|
9
|
|
|
|
|
243
|
|
15
|
9
|
|
|
9
|
|
3052
|
use Net::Etcd::KV::Txn; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
229
|
|
16
|
9
|
|
|
9
|
|
2841
|
use Net::Etcd::KV::Op; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
228
|
|
17
|
9
|
|
|
9
|
|
2841
|
use Net::Etcd::KV::Compare; |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
276
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
with 'Net::Etcd::Role::Actions'; |
20
|
9
|
|
|
9
|
|
49
|
use namespace::clean; |
|
9
|
|
|
|
|
12
|
|
|
9
|
|
|
|
|
28
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 NAME |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Net::Etcd::KV |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $VERSION = '0.022'; |
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; |