| 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
| |||||||||||||||||||||||||||||
| 43 | 69 | my $cxn = $cxns->[ $self->next_cxn_num ]; | |||||||||||||||||||||||||||
| 44 | 69 | ▶ | return $cxn | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$cxn->is_live or $cxn->next_ping < time
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
| |||||||||||||||||||||||||||||
| 45 | if $cxn->is_live | ||||||||||||||||||||||||||||
| 46 | || $cxn->next_ping < time(); | ||||||||||||||||||||||||||||
| 47 | 13 | ▶ | push @$dead, $cxn unless grep { $_ eq $cxn } @$dead; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 2 | ▶ | if ( @$dead and $self->retries <= $self->max_retries ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@$dead and $self->retries <= $self->max_retries
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
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||