| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Consul::Service; |
|
2
|
|
|
|
|
|
|
$Consul::Service::VERSION = '0.025'; |
|
3
|
9
|
|
|
9
|
|
68
|
use namespace::autoclean; |
|
|
9
|
|
|
|
|
20
|
|
|
|
9
|
|
|
|
|
84
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
9
|
|
|
9
|
|
905
|
use Moo; |
|
|
9
|
|
|
|
|
25
|
|
|
|
9
|
|
|
|
|
57
|
|
|
6
|
9
|
|
|
9
|
|
3183
|
use Types::Standard qw(Str Int Bool ArrayRef); |
|
|
9
|
|
|
|
|
19
|
|
|
|
9
|
|
|
|
|
82
|
|
|
7
|
9
|
|
|
9
|
|
9723
|
use Carp qw(croak); |
|
|
9
|
|
|
|
|
22
|
|
|
|
9
|
|
|
|
|
638
|
|
|
8
|
9
|
|
|
9
|
|
66
|
use JSON::MaybeXS; |
|
|
9
|
|
|
|
|
42
|
|
|
|
9
|
|
|
|
|
4460
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has name => ( is => 'ro', isa => Str, required => 1 ); |
|
11
|
|
|
|
|
|
|
has id => ( is => 'ro', isa => Str ); |
|
12
|
|
|
|
|
|
|
has address => ( is => 'ro', isa => Str ); |
|
13
|
|
|
|
|
|
|
has port => ( is => 'ro', isa => Int ); |
|
14
|
|
|
|
|
|
|
has tags => ( is => 'ro', isa => ArrayRef[Str], default => sub { [] } ); |
|
15
|
|
|
|
|
|
|
has script => ( is => 'ro', isa => Str ); |
|
16
|
|
|
|
|
|
|
has interval => ( is => 'ro', isa => Str ); |
|
17
|
|
|
|
|
|
|
has ttl => ( is => 'ro', isa => Str ); |
|
18
|
|
|
|
|
|
|
has enable_tag_override => ( is => 'ro', isa => Bool, default => sub { 0 } ); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub BUILD { |
|
21
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
22
|
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $A = defined $self->script; |
|
24
|
0
|
|
|
|
|
|
my $B = defined $self->interval; |
|
25
|
0
|
|
|
|
|
|
my $C = defined $self->ttl; |
|
26
|
|
|
|
|
|
|
|
|
27
|
0
|
0
|
0
|
|
|
|
croak "Invalid check arguments, required: script, interval OR ttl" |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
28
|
|
|
|
|
|
|
unless (!$A && !$B && !$C) || ($A && $B && !$C) || (!$A && !$B && $C) |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
|
|
0
|
0
|
|
sub to_json { shift->_json } |
|
32
|
|
|
|
|
|
|
has _json => ( is => 'lazy', isa => Str ); |
|
33
|
|
|
|
|
|
|
sub _build__json { |
|
34
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
|
35
|
0
|
0
|
|
|
|
|
encode_json({ |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Name => $self->name, |
|
37
|
|
|
|
|
|
|
defined $self->id ? ( ID => $self->id ) : (), |
|
38
|
|
|
|
|
|
|
defined $self->port ? ( Port => $self->port ) : (), |
|
39
|
|
|
|
|
|
|
defined $self->address ? ( Address => $self->address ) : (), |
|
40
|
|
|
|
|
|
|
Tags => $self->tags, |
|
41
|
|
|
|
|
|
|
defined $self->script ? ( Script => $self->script ) : (), |
|
42
|
|
|
|
|
|
|
defined $self->interval ? ( Interval => $self->interval ) : (), |
|
43
|
|
|
|
|
|
|
defined $self->ttl ? ( TTL => $self->ttl ) : (), |
|
44
|
|
|
|
|
|
|
EnableTagOverride => ($self->enable_tag_override ? \1 : \0), |
|
45
|
|
|
|
|
|
|
}); |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |