line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Consul::Check; |
2
|
|
|
|
|
|
|
$Consul::Check::VERSION = '0.025'; |
3
|
9
|
|
|
9
|
|
71
|
use namespace::autoclean; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
69
|
|
4
|
|
|
|
|
|
|
|
5
|
9
|
|
|
9
|
|
5244
|
use Moo::Role; |
|
9
|
|
|
|
|
78284
|
|
|
9
|
|
|
|
|
59
|
|
6
|
9
|
|
|
9
|
|
3559
|
use Types::Standard qw(Str HashRef Enum); |
|
9
|
|
|
|
|
25
|
|
|
9
|
|
|
|
|
73
|
|
7
|
|
|
|
|
|
|
|
8
|
9
|
|
|
9
|
|
7137
|
use Carp qw(croak); |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
4373
|
|
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.025'; |
61
|
9
|
|
|
9
|
|
102
|
use Moo; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
72
|
|
62
|
9
|
|
|
9
|
|
3384
|
use Types::Standard qw(Str); |
|
9
|
|
|
|
|
30
|
|
|
9
|
|
|
|
|
993
|
|
63
|
9
|
|
|
9
|
|
4438
|
use JSON::MaybeXS; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
1818
|
|
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.025'; |
83
|
9
|
|
|
9
|
|
68
|
use Moo; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
42
|
|
84
|
9
|
|
|
9
|
|
3376
|
use Types::Standard qw(Str); |
|
9
|
|
|
|
|
24
|
|
|
9
|
|
|
|
|
42
|
|
85
|
9
|
|
|
9
|
|
4478
|
use JSON::MaybeXS; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
1917
|
|
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.025'; |
103
|
9
|
|
|
9
|
|
79
|
use Moo; |
|
9
|
|
|
|
|
103
|
|
|
9
|
|
|
|
|
43
|
|
104
|
9
|
|
|
9
|
|
3156
|
use Types::Standard qw(Str Bool); |
|
9
|
|
|
|
|
102
|
|
|
9
|
|
|
|
|
60
|
|
105
|
9
|
|
|
9
|
|
5483
|
use JSON::MaybeXS; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
2022
|
|
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.025'; |
128
|
9
|
|
|
9
|
|
70
|
use Moo; |
|
9
|
|
|
|
|
32
|
|
|
9
|
|
|
|
|
49
|
|
129
|
9
|
|
|
9
|
|
3222
|
use Types::Standard qw(Str); |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
40
|
|
130
|
9
|
|
|
9
|
|
4426
|
use JSON::MaybeXS; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
1775
|
|
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.025'; |
150
|
9
|
|
|
9
|
|
67
|
use Moo; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
49
|
|
151
|
9
|
|
|
9
|
|
2994
|
use Types::Standard qw(Str); |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
50
|
|
152
|
9
|
|
|
9
|
|
4497
|
use JSON::MaybeXS; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
2110
|
|
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; |