line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
15
|
use utf8; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
18
|
|
2
|
|
|
|
|
|
|
package Etcd3::Lease::Grant; |
3
|
|
|
|
|
|
|
|
4
|
4
|
|
|
4
|
|
122
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
67
|
|
5
|
4
|
|
|
4
|
|
12
|
use warnings; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
87
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
15
|
use Moo; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
21
|
|
8
|
4
|
|
|
4
|
|
854
|
use Types::Standard qw(Str Int Bool HashRef ArrayRef); |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
20
|
|
9
|
4
|
|
|
4
|
|
2401
|
use Data::Dumper; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
184
|
|
10
|
4
|
|
|
4
|
|
14
|
use JSON; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
17
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Etcd3::Role::Actions'; |
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
392
|
use namespace::clean; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
20
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Etcd3::Lease::Grant |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.005'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
LeaseGrant creates a lease which expires if the server does not receive a keepAlive within |
27
|
|
|
|
|
|
|
a given time to live period. All keys attached to the lease will be expired and deleted if |
28
|
|
|
|
|
|
|
the lease expires. Each expired key generates a delete event in the event history. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 endpoint |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
/lease/grant |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has endpoint => ( |
37
|
|
|
|
|
|
|
is => 'ro', |
38
|
|
|
|
|
|
|
isa => Str, |
39
|
|
|
|
|
|
|
default => '/lease/grant' |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 TTL |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
TTL is the advisory time-to-live in seconds. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
has TTL => ( |
49
|
|
|
|
|
|
|
is => 'ro', |
50
|
|
|
|
|
|
|
isa => Str, |
51
|
|
|
|
|
|
|
required => 1, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 ID |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
ID is the requested ID for the lease. If ID is set to 0, the lessor chooses an ID. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
has ID => ( |
61
|
|
|
|
|
|
|
is => 'ro', |
62
|
|
|
|
|
|
|
required => 1, |
63
|
|
|
|
|
|
|
coerce => sub { return $_[0]; }, |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 json_args |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
arguments that will be sent to the api |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
has json_args => ( is => 'lazy', ); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub _build_json_args { |
75
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
76
|
|
|
|
|
|
|
# print STDERR Dumper($self); |
77
|
0
|
|
|
|
|
|
my $args; |
78
|
0
|
|
|
|
|
|
for my $key ( keys %{$self} ) { |
|
0
|
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
unless ( $key =~ /(?:_client|json_args|endpoint)$/ ) { |
80
|
0
|
|
|
|
|
|
$args->{$key} = $self->{$key}; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
0
|
|
|
|
|
|
return to_json($args); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 init |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub init { |
91
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
92
|
0
|
|
|
|
|
|
$self->json_args; |
93
|
0
|
|
|
|
|
|
return $self; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |