« lib/IO/K8s/Role/NetworkPolicy.pm
↑ Summary
lib/IO/K8s/ApiextensionsApiserver/Pkg/Apis/Apiextensions/V1/JSONSchemaPropsOrStringArray.pm »
| 1 | package IO::K8s::Role::Loadbalanced; | ||||||||||||||||||||
| 2 | # ABSTRACT: Role for traffic distribution (weighted backends, mirroring) | ||||||||||||||||||||
| 3 | 7 | our $VERSION = '1.112'; | |||||||||||||||||||
| 4 | 7 | ▶ | use Moo::Role; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | # The fluent setters below build the spec through IO::K8s::Role::SpecBuilder | ||||||||||||||||||||
| 7 | # rather than by hand, so that role is a hard dependency of this one (k103). | ||||||||||||||||||||
| 8 | # IO::K8s::Role::APIObject composes SpecBuilder for every top-level Kind, so | ||||||||||||||||||||
| 9 | # these are satisfied for anything built with IO::K8s::APIObject; a class | ||||||||||||||||||||
| 10 | # that composes this role without them now fails at composition time, | ||||||||||||||||||||
| 11 | # naming the missing method, instead of at the first setter call. | ||||||||||||||||||||
| 12 | 7 | requires qw( spec_array spec_get spec_push spec_set ); | |||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 7 | ▶ | sub set_weighted { | ||||||||||||||||||
|
Subroutine
set_weighted: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||
| 16 | 7 | my ($self, $name, $weight) = @_; | |||||||||||||||||||
| 17 | 7 | my $services = $self->spec_array('weighted.services'); | |||||||||||||||||||
| 18 | 7 | for my $i (0 .. $#$services) { | |||||||||||||||||||
| 19 | 4 | ▶ | next unless ($self->spec_get("weighted.services.$i.name") // '') eq $name; | ||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->spec_get("weighted.services.$i.name") // ""
MC/DC0%0/1
$self->spec_get("weighted.services.$i.name") // ""
$self->spec_get("weighted.services.$i.name")
Truth table50%1/2
A
A= $self->spec_get("weighted.services.$i.name")
| |||||||||||||||||||||
| 20 | 2 | $self->spec_set("weighted.services.$i.weight", $weight); | |||||||||||||||||||
| 21 | 2 | return $self; | |||||||||||||||||||
| 22 | } | ||||||||||||||||||||
| 23 | 5 | $self->spec_push('weighted.services', { name => $name, weight => $weight }); | |||||||||||||||||||
| 24 | 5 | return $self; | |||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 2 | ▶ | sub mirror_to { | ||||||||||||||||||
|
Subroutine
mirror_to: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||
| 29 | 2 | my ($self, $name, %opts) = @_; | |||||||||||||||||||
| 30 | $self->spec_push('mirroring.mirrors', { | ||||||||||||||||||||
| 31 | name => $name, | ||||||||||||||||||||
| 32 | 2 | ▶ | $opts{percent} ? (percent => $opts{percent}) : (), | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 33 | }); | ||||||||||||||||||||
| 34 | 2 | return $self; | |||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 7 | 1; | |||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | __END__ | ||||||||||||||||||||