Etcd/KV.pm

filter: Statementstmt 59.0% 39 / 66 Branchbran 0.0% 0 / 30 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 12 / 18 Podpod 100% 6 / 6 totaltotal 47.5% 57 / 120 CC 16 SCAR 23.9
CC
16
Cov
41%
range
20.0
deleterange
20.0
put
20.0
CRAP 10.9
« Etcd/KV/Txn.pm ↑ Summary Etcd/KV/Op.pm »
1 9 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package Net::Etcd::KV;
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 =encoding utf8
8  
9 =cut
10 9 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 9 ▶use Types::Standard qw(Str Int Bool HashRef ArrayRef);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 9 ▶use Net::Etcd::KV::Put;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 9 ▶use Net::Etcd::KV::Range;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 9 ▶use Net::Etcd::KV::DeleteRange;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 9 ▶use Net::Etcd::KV::Txn;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 9 ▶use Net::Etcd::KV::Op;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 9 ▶use Net::Etcd::KV::Compare;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 9 with 'Net::Etcd::Role::Actions';
20 9 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 =head1 NAME
23  
24 Net::Etcd::KV
25  
26 =cut
27  
28 9 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 0 ▶sub range {
Subroutine range: not called CC=4 SCAR=30.0
Pod documented
48 0 my ( $self, $options ) = @_;
49 0 ▶ my $cb = pop if ref $_[-1] eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[-1] eq "CODE" 0 0 0
50 0 ▶ my $range = Net::Etcd::KV::Range->new(
Branch: 1 branch
BranchTrueFalseTotal
$options ? : 0 0 0
51 endpoint => '/kv/range',
52 etcd => $self,
53 cb => $cb,
54 ( $options ? %$options : () ),
55 );
56 0 ▶ $range->request unless $range->hold;
Branch: 1 branch
BranchTrueFalseTotal
unless $range->hold 0 0 0
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 0 ▶sub deleterange {
Subroutine deleterange: not called CC=4 SCAR=30.0
Pod documented
71 0 my ( $self, $options ) = @_;
72 0 ▶ my $cb = pop if ref $_[-1] eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[-1] eq "CODE" 0 0 0
73 0 ▶ my $delete_range = Net::Etcd::KV::DeleteRange->new(
Branch: 1 branch
BranchTrueFalseTotal
$options ? : 0 0 0
74 endpoint => '/kv/deleterange',
75 etcd => $self,
76 cb => $cb,
77 ( $options ? %$options : () ),
78 );
79 0 ▶ $delete_range->request unless $delete_range->hold;
Branch: 1 branch
BranchTrueFalseTotal
unless $delete_range->hold 0 0 0
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 0 ▶sub put {
Subroutine put: not called CC=4 SCAR=30.0
Pod documented
94 0 my ( $self, $options ) = @_;
95 0 ▶ my $cb = pop if ref $_[-1] eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[-1] eq "CODE" 0 0 0
96 0 ▶ my $put = Net::Etcd::KV::Put->new(
Branch: 1 branch
BranchTrueFalseTotal
$options ? : 0 0 0
97 endpoint => '/kv/put',
98 etcd => $self,
99 cb => $cb,
100 ( $options ? %$options : () ),
101 );
102 0 ▶ $put->request unless $put->hold;
Branch: 1 branch
BranchTrueFalseTotal
unless $put->hold 0 0 0
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 0 ▶sub txn {
Subroutine txn: not called CC=3 SCAR=24.8
Pod documented
116 0 my ( $self, $options ) = @_;
117 0 ▶ my $cb = pop if ref $_[-1] eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[-1] eq "CODE" 0 0 0
118 0 ▶ my $txn = Net::Etcd::KV::Txn->new(
Branch: 1 branch
BranchTrueFalseTotal
$options ? : 0 0 0
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 0 ▶sub op {
Subroutine op: not called CC=3 SCAR=24.8
Pod documented
133 0 my ( $self, $options ) = @_;
134 0 ▶ my $cb = pop if ref $_[-1] eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[-1] eq "CODE" 0 0 0
135 0 ▶ my $op = Net::Etcd::KV::Op->new(
Branch: 1 branch
BranchTrueFalseTotal
$options ? : 0 0 0
136 %$self,
137 ( $options ? %$options : () ),
138 );
139 0 return $op->create;
140 }
141  
142 =head2 compare
143  
144 =cut
145  
146 0 ▶sub compare {
Subroutine compare: not called CC=3 SCAR=24.8
Pod documented
147 0 my ( $self, $options ) = @_;
148 0 ▶ my $cb = pop if ref $_[-1] eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[-1] eq "CODE" 0 0 0
149 0 ▶ my $cmp = Net::Etcd::KV::Compare->new(
Branch: 1 branch
BranchTrueFalseTotal
$options ? : 0 0 0
150 %$self,
151 ( $options ? %$options : () ),
152 );
153 0 return $cmp->json_args;
154 }
155  
156 9 1;
« Etcd/KV/Txn.pm ↑ Summary Etcd/KV/Op.pm »