line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Consul::Service; |
2
|
|
|
|
|
|
|
$Consul::Service::VERSION = '0.026'; |
3
|
9
|
|
|
9
|
|
57
|
use namespace::autoclean; |
|
9
|
|
|
|
|
24
|
|
|
9
|
|
|
|
|
65
|
|
4
|
|
|
|
|
|
|
|
5
|
9
|
|
|
9
|
|
706
|
use Moo; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
43
|
|
6
|
9
|
|
|
9
|
|
2732
|
use Types::Standard qw(Str Int Bool ArrayRef); |
|
9
|
|
|
|
|
26
|
|
|
9
|
|
|
|
|
62
|
|
7
|
9
|
|
|
9
|
|
6964
|
use Carp qw(croak); |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
445
|
|
8
|
9
|
|
|
9
|
|
45
|
use JSON::MaybeXS; |
|
9
|
|
|
|
|
13
|
|
|
9
|
|
|
|
|
3741
|
|
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; |