line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Consul::API::Event; |
2
|
|
|
|
|
|
|
$Consul::API::Event::VERSION = '0.027'; |
3
|
9
|
|
|
9
|
|
5042
|
use namespace::autoclean; |
|
9
|
|
|
|
|
71
|
|
|
9
|
|
|
|
|
55
|
|
4
|
|
|
|
|
|
|
|
5
|
9
|
|
|
9
|
|
705
|
use Moo::Role; |
|
9
|
|
|
|
|
56
|
|
|
9
|
|
|
|
|
69
|
|
6
|
9
|
|
|
9
|
|
3024
|
use Types::Standard qw(Str); |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
59
|
|
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
|
|
5657
|
use Moo; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
52
|
|
25
|
|
|
|
|
|
|
|
26
|
9
|
|
|
9
|
|
3020
|
use Carp qw(croak); |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
2529
|
|
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.027'; |
46
|
9
|
|
|
9
|
|
4006
|
use Convert::Base64 qw(decode_base64); |
|
9
|
|
|
|
|
11088
|
|
|
9
|
|
|
|
|
474
|
|
47
|
|
|
|
|
|
|
|
48
|
9
|
|
|
9
|
|
66
|
use Moo; |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
393
|
|
49
|
9
|
|
|
9
|
|
2740
|
use Types::Standard qw(Str Int Maybe); |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
351
|
|
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 |