File Coverage

blib/lib/OpenSearch/Client/Role/CxnPool/Static.pm
Criterion Covered Total %
statement 17 17 100.0
branch 2 2 100.0
condition n/a
subroutine 4 4 100.0
pod 1 2 50.0
total 24 25 96.0


line stmt bran cond sub pod time code
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;
24             $OpenSearch::Client::Role::CxnPool::Static::VERSION = '3.007002';
25 37     37   17250 use Moo::Role;
  37         104  
  37         620  
26             with 'OpenSearch::Client::Role::CxnPool';
27             requires 'next_cxn';
28              
29 37     37   15410 use namespace::clean;
  37         108  
  37         321  
30              
31             #===================================
32             sub BUILD {
33             #===================================
34 81     81 0 724 my $self = shift;
35 81         159 $self->set_cxns( @{ $self->seed_nodes } );
  81         367  
36 81         210 $self->schedule_check;
37             }
38              
39             #===================================
40             sub schedule_check {
41             #===================================
42 93     93 1 169 my ($self) = @_;
43 93         1420 $self->logger->info("Forcing ping before next use on all live cxns");
44 93         2198 for my $cxn ( @{ $self->cxns } ) {
  93         283  
45 105 100       323 next if $cxn->is_dead;
46 96         287 $self->logger->infof( "Ping [%s] before next request",
47             $cxn->stringify );
48 96         3732 $cxn->force_ping;
49             }
50             }
51              
52             1;
53              
54             __END__