line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
29
|
use utf8; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
27
|
|
2
|
|
|
|
|
|
|
package Etcd3::KV::Range; |
3
|
|
|
|
|
|
|
|
4
|
5
|
|
|
5
|
|
177
|
use strict; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
92
|
|
5
|
5
|
|
|
5
|
|
24
|
use warnings; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
99
|
|
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
19
|
use Moo; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
24
|
|
8
|
5
|
|
|
5
|
|
1322
|
use Types::Standard qw(Str Int Bool HashRef ArrayRef); |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
32
|
|
9
|
5
|
|
|
5
|
|
4534
|
use MIME::Base64; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
236
|
|
10
|
5
|
|
|
5
|
|
26
|
use JSON; |
|
5
|
|
|
|
|
16
|
|
|
5
|
|
|
|
|
24
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Etcd3::Role::Actions'; |
13
|
|
|
|
|
|
|
#extends 'Etcd3::KV'; |
14
|
|
|
|
|
|
|
|
15
|
5
|
|
|
5
|
|
473
|
use namespace::clean; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
34
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Etcd3::Range |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '0.006'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Range gets the keys in the range from the key-value store. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 ACCESSORS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 endpoint |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has endpoint => ( |
36
|
|
|
|
|
|
|
is => 'ro', |
37
|
|
|
|
|
|
|
isa => Str, |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 key |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
key is the first key for the range. If range_end is not given, the request only looks up key. |
43
|
|
|
|
|
|
|
the key is encoded with base64. type bytes |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has key => ( |
48
|
|
|
|
|
|
|
is => 'ro', |
49
|
|
|
|
|
|
|
isa => Str, |
50
|
|
|
|
|
|
|
required => 1, |
51
|
|
|
|
|
|
|
coerce => sub { return encode_base64( $_[0], '' ) } |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 range_end |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
range_end is the upper bound on the requested range [key, range_end). If range_end is '\0', |
57
|
|
|
|
|
|
|
the range is all keys >= key. If the range_end is one bit larger than the given key, then |
58
|
|
|
|
|
|
|
the range requests get the all keys with the prefix (the given key). If both key and |
59
|
|
|
|
|
|
|
range_end are '\0', then range requests returns all keys. the key is encoded with base64. |
60
|
|
|
|
|
|
|
type bytes. NOTE: If range_end is not given, the request only looks up key. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
has range_end => ( |
65
|
|
|
|
|
|
|
is => 'ro', |
66
|
|
|
|
|
|
|
isa => Str, |
67
|
|
|
|
|
|
|
coerce => sub { return encode_base64( $_[0], '' ) } |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 prev_key |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
If prev_kv is set, etcd gets the previous key-value pairs before deleting it. The previous key-value |
73
|
|
|
|
|
|
|
pairs will be returned in the delete response. This is only used for delete. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
has prev_key => ( |
78
|
|
|
|
|
|
|
is => 'ro', |
79
|
|
|
|
|
|
|
isa => Bool, |
80
|
5
|
|
|
5
|
|
2258
|
coerce => sub { no strict 'refs'; return $_[0] ? JSON::true : JSON::false } |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
535
|
|
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 limit |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
limit is a limit on the number of keys returned for the request. type int64 |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
has limit => ( |
91
|
|
|
|
|
|
|
is => 'ro', |
92
|
|
|
|
|
|
|
isa => Int, |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 revision |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
revision is the point-in-time of the key-value store to use for |
98
|
|
|
|
|
|
|
the range. If revision is less or equal to zero, the range is over |
99
|
|
|
|
|
|
|
the newest key-value store. If the revision has been compacted, |
100
|
|
|
|
|
|
|
ErrCompaction is returned as a response. type int64 |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
has revision => ( |
105
|
|
|
|
|
|
|
is => 'ro', |
106
|
|
|
|
|
|
|
isa => Int, |
107
|
|
|
|
|
|
|
); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 sort_order |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sort_order is the order for returned sorted results. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
has sort_order => ( |
116
|
|
|
|
|
|
|
is => 'ro', |
117
|
|
|
|
|
|
|
isa => Int, |
118
|
|
|
|
|
|
|
); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 sort_target |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sort_target is the key-value field to use for sorting. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
has sort_target => ( |
127
|
|
|
|
|
|
|
is => 'ro', |
128
|
|
|
|
|
|
|
isa => Str, |
129
|
|
|
|
|
|
|
); |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 serializable |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
serializable sets the range request to use serializable member-local reads. |
134
|
|
|
|
|
|
|
Range requests are linearizable by default; linearizable requests have higher |
135
|
|
|
|
|
|
|
latency and lower throughput than serializable requests but reflect the current |
136
|
|
|
|
|
|
|
consensus of the cluster. For better performance, in exchange for possible stale |
137
|
|
|
|
|
|
|
reads, a serializable range request is served locally without needing to reach |
138
|
|
|
|
|
|
|
consensus with other nodes in the cluster. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
has serializable => ( |
143
|
|
|
|
|
|
|
is => 'ro', |
144
|
|
|
|
|
|
|
isa => Bool, |
145
|
5
|
|
|
5
|
|
32
|
coerce => sub { no strict 'refs'; return $_[0] ? JSON::true : JSON::false } |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
282
|
|
146
|
|
|
|
|
|
|
); |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 keys_only |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
keys_only when set returns only the keys and not the values. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=cut |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
has keys_only => ( |
155
|
|
|
|
|
|
|
is => 'ro', |
156
|
|
|
|
|
|
|
isa => Bool, |
157
|
5
|
|
|
5
|
|
22
|
coerce => sub { no strict 'refs'; return $_[0] ? JSON::true : JSON::false } |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
249
|
|
158
|
|
|
|
|
|
|
); |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head2 count_only |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
count_only when set returns only the count of the keys in the range. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=cut |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
has count_only => ( |
167
|
|
|
|
|
|
|
is => 'ro', |
168
|
|
|
|
|
|
|
isa => Bool, |
169
|
5
|
|
|
5
|
|
28
|
coerce => sub { no strict 'refs'; return $_[0] ? JSON::true : JSON::false } |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
635
|
|
170
|
|
|
|
|
|
|
); |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head2 min_mod_revision |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
min_mod_revision is the lower bound for returned key mod revisions; |
175
|
|
|
|
|
|
|
all keys with lesser mod revisions will be filtered away. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=cut |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
has min_mod_revision => ( |
180
|
|
|
|
|
|
|
is => 'ro', |
181
|
|
|
|
|
|
|
isa => Int, |
182
|
|
|
|
|
|
|
); |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head2 max_mod_revision |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
max_mod_revision is the upper bound for returned key mod revisions; |
187
|
|
|
|
|
|
|
all keys with greater mod revisions will be filtered away. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=cut |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
has max_mod_revision => ( |
192
|
|
|
|
|
|
|
is => 'ro', |
193
|
|
|
|
|
|
|
isa => Int, |
194
|
|
|
|
|
|
|
); |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head2 min_create_revision |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
min_create_revision is the lower bound for returned key create revisions; |
199
|
|
|
|
|
|
|
all keys with lesser create revisions will be filtered away. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=cut |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
has min_create_revision => ( |
204
|
|
|
|
|
|
|
is => 'ro', |
205
|
|
|
|
|
|
|
isa => Int, |
206
|
|
|
|
|
|
|
); |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head2 max_create_revision |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
max_create_revision is the upper bound for returned key create revisions; |
211
|
|
|
|
|
|
|
all keys with greater create revisions will be filtered away. |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=cut |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
has max_create_revision => ( |
216
|
|
|
|
|
|
|
is => 'ro', |
217
|
|
|
|
|
|
|
isa => Int, |
218
|
|
|
|
|
|
|
); |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head2 delete |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
DeleteRange deletes the given range from the key-value store. A delete request increments the |
223
|
|
|
|
|
|
|
revision of the key-value store and generates a delete event in the event history for every |
224
|
|
|
|
|
|
|
deleted key. |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
$etcd->range({key =>'test0'})->delete |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=cut |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
sub delete { |
231
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
232
|
0
|
|
|
|
|
|
$self->{endpoint} => '/kv/deleterange', |
233
|
|
|
|
|
|
|
return $self->request; |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
1; |