line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Consul::Check; |
2
|
|
|
|
|
|
|
$Consul::Check::VERSION = '0.027'; |
3
|
9
|
|
|
9
|
|
57
|
use namespace::autoclean; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
62
|
|
4
|
|
|
|
|
|
|
|
5
|
9
|
|
|
9
|
|
4460
|
use Moo::Role; |
|
9
|
|
|
|
|
67989
|
|
|
9
|
|
|
|
|
52
|
|
6
|
9
|
|
|
9
|
|
2935
|
use Types::Standard qw(Str HashRef Enum); |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
55
|
|
7
|
|
|
|
|
|
|
|
8
|
9
|
|
|
9
|
|
5825
|
use Carp qw(croak); |
|
9
|
|
|
|
|
23
|
|
|
9
|
|
|
|
|
3958
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $status_type = Enum['passing', 'warning', 'critical']; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has name => ( is => 'ro', isa => Str, required => 1 ); |
13
|
|
|
|
|
|
|
has id => ( is => 'ro', isa => Str ); |
14
|
|
|
|
|
|
|
has notes => ( is => 'ro', isa => Str ); |
15
|
|
|
|
|
|
|
has service_id => ( is => 'ro', isa => Str ); |
16
|
|
|
|
|
|
|
has status => ( is => 'ro', isa => $status_type ); |
17
|
|
|
|
|
|
|
has deregister_critical_service_after => |
18
|
|
|
|
|
|
|
( is => 'ro', isa => Str ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub smart_new { |
21
|
0
|
|
|
0
|
0
|
|
my $role = shift; |
22
|
0
|
|
|
|
|
|
my $args = Moo::Object->BUILDARGS( @_ ); |
23
|
|
|
|
|
|
|
|
24
|
0
|
0
|
|
|
|
|
if (defined $args->{script}) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
return Consul::Check::Script->new( $args ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
elsif (defined $args->{ttl}) { |
28
|
0
|
|
|
|
|
|
return Consul::Check::TTL->new( $args ); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
elsif (defined $args->{http}) { |
31
|
0
|
|
|
|
|
|
return Consul::Check::HTTP->new( $args ); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
elsif (defined $args->{tcp}) { |
34
|
0
|
|
|
|
|
|
return Consul::Check::TCP->new( $args ); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
elsif (defined $args->{docker_container_id}) { |
37
|
0
|
|
|
|
|
|
return Consul::Check::Docker->new( $args ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
croak 'Cannot create Check object because neither script, ttl, http, tcp, or docker_container_id are set'; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
0
|
|
|
sub _to_json_hash { %{shift->_json_hash} } |
|
0
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has _json_hash => ( is => 'lazy', isa => HashRef[Str] ); |
45
|
|
|
|
|
|
|
sub _build__json_hash { |
46
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
47
|
|
|
|
|
|
|
{ |
48
|
0
|
0
|
|
|
|
|
Name => $self->name, |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
49
|
|
|
|
|
|
|
defined $self->id ? ( ID => $self->id ) : (), |
50
|
|
|
|
|
|
|
defined $self->notes ? ( Notes => $self->notes ) : (), |
51
|
|
|
|
|
|
|
defined $self->service_id ? ( ServiceID => $self->service_id ) : (), |
52
|
|
|
|
|
|
|
defined $self->status ? ( Status => $self->status ) : (), |
53
|
|
|
|
|
|
|
defined $self->deregister_critical_service_after ? ( |
54
|
|
|
|
|
|
|
DeregisterCriticalServiceAfter => $self->deregister_critical_service_after |
55
|
|
|
|
|
|
|
) : (), |
56
|
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
package Consul::Check::Script; |
60
|
|
|
|
|
|
|
$Consul::Check::Script::VERSION = '0.027'; |
61
|
9
|
|
|
9
|
|
85
|
use Moo; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
51
|
|
62
|
9
|
|
|
9
|
|
3056
|
use Types::Standard qw(Str); |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
38
|
|
63
|
9
|
|
|
9
|
|
4786
|
use JSON::MaybeXS; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
1672
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
has script => ( is => 'ro', isa => Str, required => 1 ); |
66
|
|
|
|
|
|
|
has interval => ( is => 'ro', isa => Str, required => 1 ); |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
0
|
0
|
|
sub to_json { shift->_json } |
69
|
|
|
|
|
|
|
has _json => ( is => 'lazy', isa => Str ); |
70
|
|
|
|
|
|
|
sub _build__json { |
71
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
72
|
0
|
|
|
|
|
|
encode_json({ |
73
|
|
|
|
|
|
|
$self->_to_json_hash, |
74
|
|
|
|
|
|
|
Script => $self->script, |
75
|
|
|
|
|
|
|
Interval => $self->interval, |
76
|
|
|
|
|
|
|
}); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
with qw(Consul::Check); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
package Consul::Check::TTL; |
82
|
|
|
|
|
|
|
$Consul::Check::TTL::VERSION = '0.027'; |
83
|
9
|
|
|
9
|
|
60
|
use Moo; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
34
|
|
84
|
9
|
|
|
9
|
|
2667
|
use Types::Standard qw(Str); |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
39
|
|
85
|
9
|
|
|
9
|
|
3665
|
use JSON::MaybeXS; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
1712
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
has ttl => ( is => 'ro', isa => Str, required => 1 ); |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
0
|
0
|
|
sub to_json { shift->_json } |
90
|
|
|
|
|
|
|
has _json => ( is => 'lazy', isa => Str ); |
91
|
|
|
|
|
|
|
sub _build__json { |
92
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
93
|
0
|
|
|
|
|
|
encode_json({ |
94
|
|
|
|
|
|
|
$self->_to_json_hash, |
95
|
|
|
|
|
|
|
TTL => $self->ttl, |
96
|
|
|
|
|
|
|
}); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
with qw(Consul::Check); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
package Consul::Check::HTTP; |
102
|
|
|
|
|
|
|
$Consul::Check::HTTP::VERSION = '0.027'; |
103
|
9
|
|
|
9
|
|
57
|
use Moo; |
|
9
|
|
|
|
|
102
|
|
|
9
|
|
|
|
|
46
|
|
104
|
9
|
|
|
9
|
|
2651
|
use Types::Standard qw(Str Bool); |
|
9
|
|
|
|
|
85
|
|
|
9
|
|
|
|
|
42
|
|
105
|
9
|
|
|
9
|
|
4758
|
use JSON::MaybeXS; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
1747
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
has http => ( is => 'ro', isa => Str, required => 1 ); |
108
|
|
|
|
|
|
|
has interval => ( is => 'ro', isa => Str, required => 1 ); |
109
|
|
|
|
|
|
|
has tls_skip_verify => ( is => 'ro', isa => Bool ); |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
0
|
0
|
|
sub to_json { shift->_json } |
112
|
|
|
|
|
|
|
has _json => ( is => 'lazy', isa => Str ); |
113
|
|
|
|
|
|
|
sub _build__json { |
114
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
115
|
0
|
0
|
|
|
|
|
encode_json({ |
|
|
0
|
|
|
|
|
|
116
|
|
|
|
|
|
|
$self->_to_json_hash, |
117
|
|
|
|
|
|
|
HTTP => $self->http, |
118
|
|
|
|
|
|
|
Interval => $self->interval, |
119
|
|
|
|
|
|
|
defined $self->tls_skip_verify ? ( |
120
|
|
|
|
|
|
|
TLSSkipVerify => |
121
|
|
|
|
|
|
|
$self->tls_skip_verify ? \1 : \0 |
122
|
|
|
|
|
|
|
) : (), |
123
|
|
|
|
|
|
|
}); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
package Consul::Check::TCP; |
127
|
|
|
|
|
|
|
$Consul::Check::TCP::VERSION = '0.027'; |
128
|
9
|
|
|
9
|
|
57
|
use Moo; |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
36
|
|
129
|
9
|
|
|
9
|
|
2702
|
use Types::Standard qw(Str); |
|
9
|
|
|
|
|
36
|
|
|
9
|
|
|
|
|
51
|
|
130
|
9
|
|
|
9
|
|
3861
|
use JSON::MaybeXS; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
1493
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
has tcp => ( is => 'ro', isa => Str, required => 1 ); |
133
|
|
|
|
|
|
|
has interval => ( is => 'ro', isa => Str, required => 1 ); |
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
0
|
0
|
|
sub to_json { shift->_json } |
136
|
|
|
|
|
|
|
has _json => ( is => 'lazy', isa => Str ); |
137
|
|
|
|
|
|
|
sub _build__json { |
138
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
139
|
0
|
|
|
|
|
|
encode_json({ |
140
|
|
|
|
|
|
|
$self->_to_json_hash, |
141
|
|
|
|
|
|
|
TCP => $self->tcp, |
142
|
|
|
|
|
|
|
Interval => $self->interval, |
143
|
|
|
|
|
|
|
}); |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
with qw(Consul::Check); |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
package Consul::Check::Docker; |
149
|
|
|
|
|
|
|
$Consul::Check::Docker::VERSION = '0.027'; |
150
|
9
|
|
|
9
|
|
58
|
use Moo; |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
31
|
|
151
|
9
|
|
|
9
|
|
2813
|
use Types::Standard qw(Str); |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
41
|
|
152
|
9
|
|
|
9
|
|
3812
|
use JSON::MaybeXS; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
1785
|
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
has docker_container_id => ( is => 'ro', isa => Str, required => 1 ); |
155
|
|
|
|
|
|
|
has interval => ( is => 'ro', isa => Str, required => 1 ); |
156
|
|
|
|
|
|
|
has shell => ( is => 'ro', isa => Str, required => 1 ); |
157
|
|
|
|
|
|
|
|
158
|
0
|
|
|
0
|
0
|
|
sub to_json { shift->_json } |
159
|
|
|
|
|
|
|
has _json => ( is => 'lazy', isa => Str ); |
160
|
|
|
|
|
|
|
sub _build__json { |
161
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
162
|
0
|
|
|
|
|
|
encode_json({ |
163
|
|
|
|
|
|
|
$self->_to_json_hash, |
164
|
|
|
|
|
|
|
DockerContainerID => $self->docker_container_id, |
165
|
|
|
|
|
|
|
Interval => $self->interval, |
166
|
|
|
|
|
|
|
Shell => $self->shell, |
167
|
|
|
|
|
|
|
}); |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
with qw(Consul::Check); |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
1; |