Client/CxnPool/Static.pm

filter: Statementstmt 100% 27 / 27 Branchbran 100% 10 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 100% 42 / 42 CC 8 SCAR 18.1
CC
8
Cov
100%
next_cxn
8.0
BEGIN
1.0
BEGIN
1.0
CRAP 6.1
« Client/Error.pm ↑ Summary Client/CxnPool/Sniff.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::CxnPool::Static;
24 38 $OpenSearch::Client::CxnPool::Static::VERSION = '3.007011';
25 38 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 38 with 'OpenSearch::Client::Role::CxnPool::Static',
27 'OpenSearch::Client::Role::Is_Sync';
28 38 ▶use OpenSearch::Client::Util qw(throw);
Subroutine BEGIN: called CC=1 SCAR=0.0
29 38 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 #===================================
32 54 ▶sub next_cxn {
Subroutine next_cxn: called CC=8 SCAR=20.8
Pod documented
33 #===================================
34 54 my ($self) = @_;
35  
36 54 my $cxns = $self->cxns;
37 54 my $total = @$cxns;
38  
39 54 my $now = time();
40 54 my @skipped;
41  
42 54 ▶ while ( $total-- ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($total--) 63 12 75
43 63 my $cxn = $cxns->[ $self->next_cxn_num ];
44 63 ▶ return $cxn if $cxn->is_live;
Branch: 1 branch
BranchTrueFalseTotal
if $cxn->is_live 14 49 63
45  
46 49 ▶ if ( $cxn->next_ping < $now ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cxn->next_ping < $now) { } 40 9 49
47 40 ▶ return $cxn if $cxn->pings_ok;
Branch: 1 branch
BranchTrueFalseTotal
if $cxn->pings_ok 28 12 40
48 }
49 else {
50 9 push @skipped, $cxn;
51 }
52 }
53  
54 12 for my $cxn (@skipped) {
55 7 ▶ return $cxn if $cxn->pings_ok;
Branch: 1 branch
BranchTrueFalseTotal
if $cxn->pings_ok 5 2 7
56 }
57  
58 7 $_->force_ping for @$cxns;
59  
60 7 throw( "NoNodes", "No nodes are available: [" . $self->cxns_str . ']' );
61 }
62  
63 38 1;
64  
65 __END__
« Client/Error.pm ↑ Summary Client/CxnPool/Sniff.pm »