| 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 | 37 | $Search::Elasticsearch::Role::CxnPool::Static::VERSION = '8.12'; | |||||||||
| 20 | 37 | ▶ | use Moo::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 37 | with 'Search::Elasticsearch::Role::CxnPool'; | |||||||||
| 22 | 37 | requires 'next_cxn'; | |||||||||
| 23 | |||||||||||
| 24 | 37 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | #=================================== | ||||||||||
| 27 | 81 | ▶ | sub BUILD { | ||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 28 | #=================================== | ||||||||||
| 29 | 81 | my $self = shift; | |||||||||
| 30 | 81 | $self->set_cxns( @{ $self->seed_nodes } ); | |||||||||
| 31 | 81 | $self->schedule_check; | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | #=================================== | ||||||||||
| 35 | 93 | ▶ | sub schedule_check { | ||||||||
|
Subroutine
schedule_check: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 36 | #=================================== | ||||||||||
| 37 | 93 | my ($self) = @_; | |||||||||
| 38 | 93 | $self->logger->info("Forcing ping before next use on all live cxns"); | |||||||||
| 39 | 93 | for my $cxn ( @{ $self->cxns } ) { | |||||||||
| 40 | 105 | ▶ | next if $cxn->is_dead; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 96 | $self->logger->infof( "Ping [%s] before next request", | |||||||||
| 42 | $cxn->stringify ); | ||||||||||
| 43 | 96 | $cxn->force_ping; | |||||||||
| 44 | } | ||||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 37 | 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 8.12 | ||||||||||
| 60 | |||||||||||
| 61 | =head1 METHODS | ||||||||||
| 62 | |||||||||||
| 63 | =head2 C<schedule_check()> | ||||||||||
| 64 | |||||||||||
| 65 | $cxn_pool->schedule_check | ||||||||||
| 66 | |||||||||||
| 67 | Forces a ping on each cxn in L<cxns()|Search::Elasticsearch::Role::CxnPool/cxns()> | ||||||||||
| 68 | before the next time that cxn is used for a request. | ||||||||||
| 69 | |||||||||||
| 70 | =head1 AUTHOR | ||||||||||
| 71 | |||||||||||
| 72 | Enrico Zimuel <enrico.zimuel@elastic.co> | ||||||||||
| 73 | |||||||||||
| 74 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 75 | |||||||||||
| 76 | This software is Copyright (c) 2024 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__ | ||||||||||