| 1 | 9 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | package Net::Etcd::KV::Range; | ||||||||||
| 3 | |||||||||||
| 4 | 9 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 9 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 9 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 9 | ▶ | use Types::Standard qw(Str Int Bool HashRef ArrayRef); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 9 | ▶ | use MIME::Base64; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 9 | ▶ | use JSON; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 9 | with 'Net::Etcd::Role::Actions'; | |||||||||
| 13 | |||||||||||
| 14 | 9 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | =head1 NAME | ||||||||||
| 17 | |||||||||||
| 18 | Net::Etcd::Range | ||||||||||
| 19 | |||||||||||
| 20 | =cut | ||||||||||
| 21 | |||||||||||
| 22 | 9 | 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 | 9 | 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 | 0 | ▶ | coerce => sub { return encode_base64( $_[0], '' ) } | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 51 | 9 | ); | |||||||||
| 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 | 0 | ▶ | coerce => sub { return encode_base64( $_[0], '' ) } | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 67 | 9 | ); | |||||||||
| 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 | 0 | ▶ | coerce => sub { no strict 'refs'; return $_[0] ? JSON::true : JSON::false } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
Subroutine
__ANON__: not called CC=2 SCAR=9.2
Branch: 1 branch
| |||||||||||
| 80 | 9 | ); | |||||||||
| 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 | 9 | 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 | 9 | 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 | 9 | 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 | 9 | 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 | 0 | ▶ | coerce => sub { no strict 'refs'; return $_[0] ? JSON::true : JSON::false } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
Subroutine
__ANON__: not called CC=2 SCAR=9.2
Branch: 1 branch
| |||||||||||
| 145 | 9 | ); | |||||||||
| 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 | 0 | ▶ | coerce => sub { no strict 'refs'; return $_[0] ? JSON::true : JSON::false } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
Subroutine
__ANON__: not called CC=2 SCAR=9.2
Branch: 1 branch
| |||||||||||
| 157 | 9 | ); | |||||||||
| 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 | 0 | ▶ | coerce => sub { no strict 'refs'; return $_[0] ? JSON::true : JSON::false } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
Subroutine
__ANON__: not called CC=2 SCAR=9.2
Branch: 1 branch
| |||||||||||
| 169 | 9 | ); | |||||||||
| 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 | 9 | 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 | 9 | 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 | 9 | 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 | 9 | has max_create_revision => ( | |||||||||
| 215 | is => 'ro', | ||||||||||
| 216 | isa => Int, | ||||||||||
| 217 | ); | ||||||||||
| 218 | |||||||||||
| 219 | 9 | 1; | |||||||||