| 1 | package Kubernetes::Comb::Upstream::Static; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: An upstream with fixed endpoints and no cluster behind it | ||||||||||||||||||||||||||||||||||||||||||
| 3 | 4 | our $VERSION = '0.002'; | |||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | with 'Kubernetes::Comb::Role::Upstream'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Carp qw( croak ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Future; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use Types::Standard qw( ArrayRef Bool InstanceOf Str ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use Kubernetes::Comb::Endpoint; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | has _given => ( | ||||||||||||||||||||||||||||||||||||||||||
| 17 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 18 | isa => ArrayRef, | ||||||||||||||||||||||||||||||||||||||||||
| 19 | init_arg => 'endpoints', | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 5 | ▶ | default => sub { [] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 4 | has _offered => ( | |||||||||||||||||||||||||||||||||||||||||
| 24 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||||
| 25 | isa => ArrayRef[ InstanceOf['Kubernetes::Comb::Endpoint'] ], | ||||||||||||||||||||||||||||||||||||||||||
| 26 | init_arg => undef | ||||||||||||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 51 | ▶ | sub _build__offered { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build__offered: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 51 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 31 | return [ map { | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 47 | ▶ | blessed $_ && $_->isa('Kubernetes::Comb::Endpoint') ? $_ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition60%3/5
builtin::blessed($_) and $_->isa("Kubernetes::Comb::Endpoint")
ref $_ || 'a plain scalar'
MC/DC50%1/2
builtin::blessed($_) and $_->isa("Kubernetes::Comb::Endpoint")
builtin::blessed($_)
$_->isa("Kubernetes::Comb::Endpoint")
MC/DC0%0/1
ref $_ || 'a plain scalar'
ref $_
Truth table66%2/3
A and B
A= builtin::blessed($_)B= $_->isa("Kubernetes::Comb::Endpoint")
Truth table50%1/2
A
A= ref $_
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | : ref $_ eq 'HASH' ? $self->endpoint_class->new(%$_) | ||||||||||||||||||||||||||||||||||||||||||
| 34 | : croak ref($self).': an endpoint is a hashref or a Kubernetes::Comb::Endpoint, got ' | ||||||||||||||||||||||||||||||||||||||||||
| 35 | .( ref $_ || 'a plain scalar' ); | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 51 | } @{ $self->_given } ]; | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 4 | has phase => ( is => 'ro', isa => Str, default => 'Running' ); | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 18 | ▶ | has via => ( is => 'ro', isa => ArrayRef[Str], default => sub { [] } ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 4 | has reachable => ( is => 'ro', isa => Bool, coerce => 1, default => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 4 | has message => ( is => 'ro', isa => Str, predicate => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 51 | ▶ | sub BUILD { $_[0]->_offered } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 45 | ▶ | sub endpoint_class { 'Kubernetes::Comb::Endpoint' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
endpoint_class: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 44 | ▶ | sub status { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
status: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 44 | my ( $self, $comb ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 59 | return Future->done( { | ||||||||||||||||||||||||||||||||||||||||||
| 60 | reachable => $self->reachable ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||
| 61 | phase => $self->phase, | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 44 | ▶ | via => [ @{ $self->via } ], | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | ( $self->has_message ? ( message => $self->message ) : () ) | ||||||||||||||||||||||||||||||||||||||||||
| 64 | } ); | ||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 41 | ▶ | sub endpoints { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
endpoints: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 41 | my ( $self, $comb ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 41 | return Future->done( [ @{ $self->_offered } ] ); | |||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | __END__ | ||||||||||||||||||||||||||||||||||||||||||