Elasticsearch/Role/CxnPool/Static/NoPing.pm

filter: Statementstmt 97.3% 36 / 37 Branchbran 87.5% 7 / 8 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 4 totaltotal 85.5% 59 / 69 CC 8 SCAR 14.8
CC
8
Cov
92%
next_cxn
8.2
BEGIN
1.0
BEGIN
1.0
CRAP 4.4
« Elasticsearch/CxnPool/Sniff.pm ↑ Summary Elasticsearch/Util.pm »
1 package Search::Elasticsearch::Role::CxnPool::Static::NoPing;
2 7 $Search::Elasticsearch::Role::CxnPool::Static::NoPing::VERSION = '6.80';
3 7 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 with 'Search::Elasticsearch::Role::CxnPool';
5  
6 7 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 7 has 'max_retries' => ( is => 'lazy' );
9 7 ▶has '_dead_cxns' => ( is => 'ro', default => sub { [] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
10  
11 #===================================
12 sub next_cxn {
13 #===================================
14 58 ▶ my $self = shift;
Subroutine next_cxn: called CC=8 SCAR=21.1
Pod undocumented
15  
16 58 my $cxns = $self->cxns;
17 58 my $total = @$cxns;
18 58 my $dead = $self->_dead_cxns;
19  
20 58 ▶ while ( $total-- ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($total--) 69 2 71
21 69 my $cxn = $cxns->[ $self->next_cxn_num ];
22 69 ▶ return $cxn
Branch: 1 branch
BranchTrueFalseTotal
if $cxn->is_live or $cxn->next_ping < time 56 13 69
Condition100%3/3
$cxn->is_live or $cxn->next_ping < time
l!l&&r!l&&!r
48813
MC/DC100%2/2
$cxn->is_live or $cxn->next_ping < time
$cxn->is_live $cxn->next_ping < time
Truth table100%3/3
A or B
A= $cxn->is_liveB= $cxn->next_ping < time
ABresult
1X1
011
000
23 if $cxn->is_live
24 || $cxn->next_ping < time();
25 13 ▶ push @$dead, $cxn unless grep { $_ eq $cxn } @$dead;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $cxn;} @$dead 12 1 13
26 }
27  
28 2 ▶ if ( @$dead and $self->retries <= $self->max_retries ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$dead and $self->retries <= $self->max_retries) 2 0 2
Condition33%1/3
@$dead and $self->retries <= $self->max_retries
!ll&&!rl&&r
002
MC/DC0%0/2
@$dead and $self->retries <= $self->max_retries
@$dead $self->retries <= $self->max_retries
Truth table33%1/3
A and B
A= @$deadB= $self->retries <= $self->max_retries
ABresult
0X0
100
111
29 2 $_->force_ping for @$dead;
30 2 return shift @$dead;
31 }
32 0 throw( "NoNodes", "No nodes are available: [" . $self->cxns_str . ']' );
33 }
34  
35 #===================================
36 4 ▶sub _build_max_retries { @{ shift->cxns } - 1 }
Subroutine _build_max_retries: called CC=1 SCAR=0.0
37 11 ▶sub _max_retries { shift->max_retries + 1 }
Subroutine _max_retries: called CC=1 SCAR=0.0
38 #===================================
39  
40 #===================================
41 sub BUILD {
42 #===================================
43 7 ▶ my $self = shift;
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
44 7 $self->set_cxns( @{ $self->seed_nodes } );
45 }
46  
47 #===================================
48 sub should_mark_dead {
49 #===================================
50 12 ▶ my ( $self, $error ) = @_;
Subroutine should_mark_dead: called CC=1 SCAR=0.0
Pod undocumented
51 12 return $error->is( 'Cxn', 'Timeout' );
52 }
53  
54 #===================================
55 after 'reset_retries' => sub {
56 #===================================
57 49 ▶ my $self = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
58 49 @{ $self->_dead_cxns } = ();
59  
60 7 };
61  
62 #===================================
63 ▶sub schedule_check { }
Subroutine schedule_check: called CC=1 SCAR=0.0
Pod undocumented
64 #===================================
65  
66 7 1;
67  
68 # ABSTRACT: A CxnPool for connecting to a remote cluster without the ability to ping.
69  
70 __END__
« Elasticsearch/CxnPool/Sniff.pm ↑ Summary Elasticsearch/Util.pm »