File Coverage

blib/lib/Net/Etcd/KV/Range.pm
Criterion Covered Total %
statement 36 36 100.0
branch n/a
condition n/a
subroutine 12 12 100.0
pod n/a
total 48 48 100.0


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