line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Consul::API::Event; |
2
|
|
|
|
|
|
|
$Consul::API::Event::VERSION = '0.026'; |
3
|
9
|
|
|
9
|
|
4497
|
use namespace::autoclean; |
|
9
|
|
|
|
|
59
|
|
|
9
|
|
|
|
|
52
|
|
4
|
|
|
|
|
|
|
|
5
|
9
|
|
|
9
|
|
637
|
use Moo::Role; |
|
9
|
|
|
|
|
52
|
|
|
9
|
|
|
|
|
50
|
|
6
|
9
|
|
|
9
|
|
2732
|
use Types::Standard qw(Str); |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
50
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
requires qw(_version_prefix _api_exec); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has _event_endpoint => ( is => 'lazy', isa => Str ); |
11
|
|
|
|
|
|
|
sub _build__event_endpoint { |
12
|
0
|
|
|
0
|
|
|
shift->_version_prefix . '/event'; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub event { |
16
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
17
|
0
|
0
|
|
|
|
|
$self = Consul->new(@_) unless ref $self; |
18
|
0
|
|
|
|
|
|
return bless \$self, "Consul::API::Event::Impl"; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
package |
22
|
|
|
|
|
|
|
Consul::API::Event::Impl; # hide from PAUSE |
23
|
|
|
|
|
|
|
|
24
|
9
|
|
|
9
|
|
4867
|
use Moo; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
40
|
|
25
|
|
|
|
|
|
|
|
26
|
9
|
|
|
9
|
|
2861
|
use Carp qw(croak); |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
2338
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub fire { |
29
|
0
|
|
|
0
|
0
|
|
my ($self, $name, %args) = @_; |
30
|
0
|
0
|
|
|
|
|
croak 'usage: $event->fire($name, [%args])' if grep { !defined } ($name); |
|
0
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
my $payload = delete $args{payload}; |
32
|
|
|
|
|
|
|
$$self->_api_exec($$self->_event_endpoint."/fire/".$name, 'PUT', %args, ($payload ? (_content => $payload) : ()), sub { |
33
|
0
|
|
|
0
|
|
|
Consul::API::Event::Event->new($_[0]) |
34
|
0
|
0
|
|
|
|
|
}); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub list { |
38
|
0
|
|
|
0
|
0
|
|
my ($self, %args) = @_; |
39
|
|
|
|
|
|
|
$$self->_api_exec($$self->_event_endpoint."/list", 'GET', %args, sub { |
40
|
0
|
|
|
0
|
|
|
[ map { Consul::API::Event::Event->new(%$_) } @{$_[0]} ] |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
}); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
package Consul::API::Event::Event; |
45
|
|
|
|
|
|
|
$Consul::API::Event::Event::VERSION = '0.026'; |
46
|
9
|
|
|
9
|
|
3746
|
use Convert::Base64 qw(decode_base64); |
|
9
|
|
|
|
|
10459
|
|
|
9
|
|
|
|
|
445
|
|
47
|
|
|
|
|
|
|
|
48
|
9
|
|
|
9
|
|
55
|
use Moo; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
349
|
|
49
|
9
|
|
|
9
|
|
2519
|
use Types::Standard qw(Str Int Maybe); |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
325
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
has id => ( is => 'ro', isa => Str, init_arg => 'ID', required => 1 ); |
52
|
|
|
|
|
|
|
has name => ( is => 'ro', isa => Str, init_arg => 'Name', required => 1 ); |
53
|
|
|
|
|
|
|
has payload => ( is => 'ro', isa => Maybe[Str], init_arg => 'Payload', required => 1, coerce => sub { defined $_[0] ? decode_base64($_[0]) : undef}); |
54
|
|
|
|
|
|
|
has node_filter => ( is => 'ro', isa => Str, init_arg => 'NodeFilter', required => 1 ); |
55
|
|
|
|
|
|
|
has service_filter => ( is => 'ro', isa => Str, init_arg => 'ServiceFilter', required => 1 ); |
56
|
|
|
|
|
|
|
has tag_filter => ( is => 'ro', isa => Str, init_arg => 'TagFilter', required => 1 ); |
57
|
|
|
|
|
|
|
has version => ( is => 'ro', isa => Int, init_arg => 'Version', required => 1 ); |
58
|
|
|
|
|
|
|
has l_time => ( is => 'ro', isa => Int, init_arg => 'LTime', required => 1 ); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=pod |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=encoding UTF-8 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 NAME |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Consul::API::Event - User event API |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SYNOPSIS |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
use Consul; |
73
|
|
|
|
|
|
|
my $event = Consul->event; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 DESCRIPTION |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
The Event API is used to fire new events and to query the available events. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This API is fully documented at L. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 METHODS |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 fire |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 list |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 SEE ALSO |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
L |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |