File Coverage

blib/lib/Etcd3/KV.pm
Criterion Covered Total %
statement 24 34 70.5
branch 0 8 0.0
condition n/a
subroutine 8 10 80.0
pod 2 2 100.0
total 34 54 62.9


line stmt bran cond sub pod time code
1 5     5   2078 use utf8;
  5         10  
  5         32  
2             package Etcd3::KV;
3              
4 5     5   169 use strict;
  5         11  
  5         85  
5 5     5   18 use warnings;
  5         11  
  5         105  
6              
7             =encoding utf8
8              
9             =cut
10 5     5   19 use Moo::Role;
  5         10  
  5         33  
11 5     5   1625 use Types::Standard qw(Str Int Bool HashRef ArrayRef);
  5         10  
  5         28  
12 5     5   6007 use Etcd3::KV::Put;
  5         17  
  5         150  
13 5     5   1702 use Etcd3::KV::Range;
  5         18  
  5         235  
14              
15             with 'Etcd3::Role::Actions';
16 5     5   46 use namespace::clean;
  5         12  
  5         36  
17              
18             =head1 NAME
19              
20             Etcd3::KV
21              
22             =cut
23              
24             our $VERSION = '0.006';
25              
26             =head1 DESCRIPTION
27              
28             Key Value role providing easy access to Put and Range classes
29              
30             =cut
31              
32             =head1 PUBLIC METHODS
33              
34             =head2 range
35              
36             Range gets the keys in the range from the key-value store.
37              
38             $etcd->range({key =>'test0', range_end => 'test100'})
39              
40             =cut
41              
42             sub range {
43 0     0 1   my ( $self, $options ) = @_;
44 0 0         my $cb = pop if ref $_[-1] eq 'CODE';
45 0 0         my $range = Etcd3::KV::Range->new(
46             %$self,
47             endpoint => '/kv/range',
48             etcd => $self,
49             cb => $cb,
50             ( $options ? %$options : () ),
51             );
52 0           $range->request;
53 0           return $range;
54             }
55              
56             =head2 put
57              
58             Put puts the given key into the key-value store. A put request increments
59             the revision of the key-value store and generates one event in the event
60             history.
61              
62             $etcd->range({key =>'test0', range_end => 'test100'})
63              
64             =cut
65              
66             sub put {
67 0     0 1   my ( $self, $options ) = @_;
68 0 0         my $cb = pop if ref $_[-1] eq 'CODE';
69 0 0         my $range = Etcd3::KV::Put->new(
70             %$self,
71             endpoint => '/kv/put',
72             etcd => $self,
73             cb => $cb,
74             ( $options ? %$options : () ),
75             );
76 0           $range->request;
77 0           return $range;
78             }
79              
80             1;