line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Consul::Check; |
2
|
|
|
|
|
|
|
$Consul::Check::VERSION = '0.026'; |
3
|
9
|
|
|
9
|
|
58
|
use namespace::autoclean; |
|
9
|
|
|
|
|
11
|
|
|
9
|
|
|
|
|
59
|
|
4
|
|
|
|
|
|
|
|
5
|
9
|
|
|
9
|
|
4189
|
use Moo::Role; |
|
9
|
|
|
|
|
63324
|
|
|
9
|
|
|
|
|
43
|
|
6
|
9
|
|
|
9
|
|
2922
|
use Types::Standard qw(Str HashRef Enum); |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
53
|
|
7
|
|
|
|
|
|
|
|
8
|
9
|
|
|
9
|
|
5572
|
use Carp qw(croak); |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
3701
|
|
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.026'; |
61
|
9
|
|
|
9
|
|
89
|
use Moo; |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
47
|
|
62
|
9
|
|
|
9
|
|
2790
|
use Types::Standard qw(Str); |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
906
|
|
63
|
9
|
|
|
9
|
|
3621
|
use JSON::MaybeXS; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
1456
|
|
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.026'; |
83
|
9
|
|
|
9
|
|
54
|
use Moo; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
33
|
|
84
|
9
|
|
|
9
|
|
2767
|
use Types::Standard qw(Str); |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
36
|
|
85
|
9
|
|
|
9
|
|
3509
|
use JSON::MaybeXS; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
1489
|
|
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.026'; |
103
|
9
|
|
|
9
|
|
60
|
use Moo; |
|
9
|
|
|
|
|
108
|
|
|
9
|
|
|
|
|
56
|
|
104
|
9
|
|
|
9
|
|
2578
|
use Types::Standard qw(Str Bool); |
|
9
|
|
|
|
|
93
|
|
|
9
|
|
|
|
|
38
|
|
105
|
9
|
|
|
9
|
|
4459
|
use JSON::MaybeXS; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
1763
|
|
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.026'; |
128
|
9
|
|
|
9
|
|
55
|
use Moo; |
|
9
|
|
|
|
|
28
|
|
|
9
|
|
|
|
|
48
|
|
129
|
9
|
|
|
9
|
|
2593
|
use Types::Standard qw(Str); |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
43
|
|
130
|
9
|
|
|
9
|
|
3492
|
use JSON::MaybeXS; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
1388
|
|
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.026'; |
150
|
9
|
|
|
9
|
|
53
|
use Moo; |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
36
|
|
151
|
9
|
|
|
9
|
|
2620
|
use Types::Standard qw(Str); |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
40
|
|
152
|
9
|
|
|
9
|
|
3666
|
use JSON::MaybeXS; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
1663
|
|
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; |