| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
3
|
|
|
3
|
|
11
|
use utf8; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
|
|
package Etcd3::Watch; |
|
3
|
|
|
|
|
|
|
|
|
4
|
3
|
|
|
3
|
|
103
|
use strict; |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
52
|
|
|
5
|
3
|
|
|
3
|
|
10
|
use warnings; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
71
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
10
|
use Moo; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
13
|
|
|
8
|
3
|
|
|
3
|
|
690
|
use Types::Standard qw(Str Int Bool HashRef ArrayRef); |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
20
|
|
|
9
|
3
|
|
|
3
|
|
1954
|
use MIME::Base64; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
150
|
|
|
10
|
3
|
|
|
3
|
|
16
|
use JSON; |
|
|
3
|
|
|
|
|
2
|
|
|
|
3
|
|
|
|
|
16
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Etcd3::Role::Actions'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
3
|
|
|
3
|
|
326
|
use namespace::clean; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
18
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Etcd3::Range |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Watch watches for events happening or that have happened. Both input and output\nare streams; |
|
27
|
|
|
|
|
|
|
the input stream is for creating and canceling watchers and the output\nstream sends events. |
|
28
|
|
|
|
|
|
|
One watch RPC can watch on multiple key ranges, streaming events\nfor several watches at once. |
|
29
|
|
|
|
|
|
|
The entire event history can be watched starting from the\nlast compaction revision. |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 endpoint |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has endpoint => ( |
|
36
|
|
|
|
|
|
|
is => 'ro', |
|
37
|
|
|
|
|
|
|
isa => Str, |
|
38
|
|
|
|
|
|
|
default => '/watch' |
|
39
|
|
|
|
|
|
|
); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 key |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
key is the first key for the range. If range_end is not given, the request only looks up key. |
|
44
|
|
|
|
|
|
|
the key is encoded with base64. type bytes |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
has key => ( |
|
49
|
|
|
|
|
|
|
is => 'ro', |
|
50
|
|
|
|
|
|
|
isa => Str, |
|
51
|
|
|
|
|
|
|
required => 1, |
|
52
|
|
|
|
|
|
|
coerce => sub { return encode_base64( $_[0], '' ) } |
|
53
|
|
|
|
|
|
|
); |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 range_end |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
range_end is the end of the range [key, range_end) to watch. If range_end is not given, only |
|
58
|
|
|
|
|
|
|
the key argument is watched. If range_end is equal to '\0', all keys greater than or equal to |
|
59
|
|
|
|
|
|
|
the key argument are watched. |
|
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 limit |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
has limit => ( |
|
74
|
|
|
|
|
|
|
is => 'ro', |
|
75
|
|
|
|
|
|
|
isa => Int, |
|
76
|
|
|
|
|
|
|
); |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 progress_notify |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
progress_notify is set so that the etcd server will periodically send a WatchResponse with no |
|
81
|
|
|
|
|
|
|
events to the new watcher if there are no recent events. It is useful when clients wish to recover |
|
82
|
|
|
|
|
|
|
a disconnected watcher starting from a recent known revision. The etcd server may decide how often |
|
83
|
|
|
|
|
|
|
it will send notifications based on current load. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
has progress_notify => ( |
|
88
|
|
|
|
|
|
|
is => 'ro', |
|
89
|
|
|
|
|
|
|
isa => Bool, |
|
90
|
3
|
|
|
3
|
|
1047
|
coerce => sub { no strict 'refs'; return $_[0] ? JSON::true : JSON::false } |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
175
|
|
|
91
|
|
|
|
|
|
|
); |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 prev_key |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
If prev_kv is set, created watcher gets the previous KV before the event happens. If the previous |
|
96
|
|
|
|
|
|
|
KV is already compacted, nothing will be returned. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
has prev_key => ( |
|
101
|
|
|
|
|
|
|
is => 'ro', |
|
102
|
|
|
|
|
|
|
isa => Bool, |
|
103
|
3
|
|
|
3
|
|
9
|
coerce => sub { no strict 'refs'; return $_[0] ? JSON::true : JSON::false } |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
584
|
|
|
104
|
|
|
|
|
|
|
); |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 json_args |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
arguments that will be sent to the api |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
has json_args => ( is => 'lazy', ); |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub _build_json_args { |
|
115
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
|
116
|
0
|
|
|
|
|
|
my $args; |
|
117
|
0
|
|
|
|
|
|
for my $key ( keys %{$self} ) { |
|
|
0
|
|
|
|
|
|
|
|
118
|
0
|
0
|
|
|
|
|
unless ( $key =~ /(?:_client|json_args|endpoint)$/ ) { |
|
119
|
0
|
|
|
|
|
|
$args->{$key} = $self->{$key}; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
} |
|
122
|
0
|
|
|
|
|
|
return to_json( { create_request => $args } ); |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 init |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub init { |
|
130
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
131
|
0
|
|
|
|
|
|
$self->json_args; |
|
132
|
0
|
|
|
|
|
|
return $self; |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |