Client/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
« Client/CxnPool/Sniff.pm ↑ Summary Client/Util.pm »
1 # OpenSearch::Client is an unofficial client for OpenSearch.
2 # It is derived from Search::Elasticsearch version 7.714
3 # License details from the original work are contained in the
4 # NOTICE file distributed with this work.
5 #
6 #-----------------------------------------------------------------------
7 # OpenSearch::Client
8 #-----------------------------------------------------------------------
9 # Copyright 2026 Mark Dootson
10 #
11 # Licensed under the Apache License, Version 2.0 (the "License");
12 # you may not use this file except in compliance with the License.
13 # You may obtain a copy of the License at
14 #
15 # http://www.apache.org/licenses/LICENSE-2.0
16 #
17 # Unless required by applicable law or agreed to in writing, software
18 # distributed under the License is distributed on an "AS IS" BASIS,
19 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 # See the License for the specific language governing permissions and
21 # limitations under the License.
22  
23 package OpenSearch::Client::Role::CxnPool::Static::NoPing;
24 7 $OpenSearch::Client::Role::CxnPool::Static::NoPing::VERSION = '3.007011';
25 7 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 7 with 'OpenSearch::Client::Role::CxnPool';
27  
28 7 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 7 has 'max_retries' => ( is => 'lazy' );
31 7 ▶has '_dead_cxns' => ( is => 'ro', default => sub { [] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
32  
33 #===================================
34 58 ▶sub next_cxn {
Subroutine next_cxn: called CC=8 SCAR=21.1
Pod undocumented
35 #===================================
36 58 my $self = shift;
37  
38 58 my $cxns = $self->cxns;
39 58 my $total = @$cxns;
40 58 my $dead = $self->_dead_cxns;
41  
42 58 ▶ while ( $total-- ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($total--) 69 2 71
43 69 my $cxn = $cxns->[ $self->next_cxn_num ];
44 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
45 if $cxn->is_live
46 || $cxn->next_ping < time();
47 13 ▶ push @$dead, $cxn unless grep { $_ eq $cxn } @$dead;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $cxn;} @$dead 12 1 13
48 }
49  
50 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
51 2 $_->force_ping for @$dead;
52 2 return shift @$dead;
53 }
54 0 throw( "NoNodes", "No nodes are available: [" . $self->cxns_str . ']' );
55 }
56  
57 #===================================
58 4 ▶sub _build_max_retries { @{ shift->cxns } - 1 }
Subroutine _build_max_retries: called CC=1 SCAR=0.0
59 11 ▶sub _max_retries { shift->max_retries + 1 }
Subroutine _max_retries: called CC=1 SCAR=0.0
60 #===================================
61  
62 #===================================
63 7 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
64 #===================================
65 7 my $self = shift;
66 7 $self->set_cxns( @{ $self->seed_nodes } );
67 }
68  
69 #===================================
70 12 ▶sub should_mark_dead {
Subroutine should_mark_dead: called CC=1 SCAR=0.0
Pod undocumented
71 #===================================
72 12 my ( $self, $error ) = @_;
73 12 return $error->is( 'Cxn', 'Timeout' );
74 }
75  
76 #===================================
77 49 ▶after 'reset_retries' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
78 #===================================
79 49 my $self = shift;
80 49 @{ $self->_dead_cxns } = ();
81  
82 7 };
83  
84 #===================================
85 12 ▶sub schedule_check { }
Subroutine schedule_check: called CC=1 SCAR=0.0
Pod undocumented
86 #===================================
87  
88 7 1;
89  
90  
91 __END__
« Client/CxnPool/Sniff.pm ↑ Summary Client/Util.pm »