line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
15
|
use utf8; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
15
|
|
2
|
|
|
|
|
|
|
package Etcd3::Watch; |
3
|
|
|
|
|
|
|
|
4
|
4
|
|
|
4
|
|
138
|
use strict; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
69
|
|
5
|
4
|
|
|
4
|
|
14
|
use warnings; |
|
4
|
|
|
|
|
3
|
|
|
4
|
|
|
|
|
79
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
13
|
use Moo; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
13
|
|
8
|
4
|
|
|
4
|
|
792
|
use Types::Standard qw(Str Int Bool HashRef ArrayRef); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
19
|
|
9
|
4
|
|
|
4
|
|
2397
|
use MIME::Base64; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
205
|
|
10
|
4
|
|
|
4
|
|
15
|
use JSON; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
30
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Etcd3::Role::Actions'; |
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
406
|
use namespace::clean; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
19
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Etcd3::Range |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.005'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Watch watches for events happening or that have happened. Both input and output are streams; |
27
|
|
|
|
|
|
|
the input stream is for creating and canceling watchers and the output stream sends events. |
28
|
|
|
|
|
|
|
One watch RPC can watch on multiple key ranges, streaming events for several watches at once. |
29
|
|
|
|
|
|
|
The entire event history can be watched starting from the last 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
|
4
|
|
|
4
|
|
1741
|
coerce => sub { no strict 'refs'; return $_[0] ? JSON::true : JSON::false } |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
272
|
|
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
|
4
|
|
|
4
|
|
15
|
coerce => sub { no strict 'refs'; return $_[0] ? JSON::true : JSON::false } |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
850
|
|
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; |