File Coverage

blib/lib/Search/Elasticsearch/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             # Licensed to Elasticsearch B.V. under one or more contributor
2             # license agreements. See the NOTICE file distributed with
3             # this work for additional information regarding copyright
4             # ownership. Elasticsearch B.V. licenses this file to you under
5             # the Apache License, Version 2.0 (the "License"); you may
6             # not use this file except in compliance with the License.
7             # You may obtain a copy of the License at
8             #
9             # http://www.apache.org/licenses/LICENSE-2.0
10             #
11             # Unless required by applicable law or agreed to in writing,
12             # software distributed under the License is distributed on an
13             # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14             # KIND, either express or implied. See the License for the
15             # specific language governing permissions and limitations
16             # under the License.
17              
18             package Search::Elasticsearch::Role::CxnPool::Static;
19             $Search::Elasticsearch::Role::CxnPool::Static::VERSION = '7.717';
20 37     37   15819 use Moo::Role;
  37         78  
  37         231  
21             with 'Search::Elasticsearch::Role::CxnPool';
22             requires 'next_cxn';
23              
24 37     37   10788 use namespace::clean;
  37         122  
  37         207  
25              
26             #===================================
27             sub BUILD {
28             #===================================
29 81     81 0 619 my $self = shift;
30 81         126 $self->set_cxns( @{ $self->seed_nodes } );
  81         358  
31 81         252 $self->schedule_check;
32             }
33              
34             #===================================
35             sub schedule_check {
36             #===================================
37 93     93 1 185 my ($self) = @_;
38 93         1415 $self->logger->info("Forcing ping before next use on all live cxns");
39 93         2522 for my $cxn ( @{ $self->cxns } ) {
  93         291  
40 105 100       335 next if $cxn->is_dead;
41 96         330 $self->logger->infof( "Ping [%s] before next request",
42             $cxn->stringify );
43 96         4118 $cxn->force_ping;
44             }
45             }
46              
47             1;
48              
49             =pod
50              
51             =encoding UTF-8
52              
53             =head1 NAME
54              
55             Search::Elasticsearch::Role::CxnPool::Static - A CxnPool role for connecting to a remote cluster with a static list of nodes.
56              
57             =head1 VERSION
58              
59             version 7.717
60              
61             =head1 METHODS
62              
63             =head2 C
64              
65             $cxn_pool->schedule_check
66              
67             Forces a ping on each cxn in L
68             before the next time that cxn is used for a request.
69              
70             =head1 AUTHOR
71              
72             Enrico Zimuel
73              
74             =head1 COPYRIGHT AND LICENSE
75              
76             This software is Copyright (c) 2022 by Elasticsearch BV.
77              
78             This is free software, licensed under:
79              
80             The Apache License, Version 2.0, January 2004
81              
82             =cut
83              
84             __END__