| 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::Cxn::Factory; | ||
| 19 | 55 | $Search::Elasticsearch::Cxn::Factory::VERSION = '8.12'; | |
| 20 | 55 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 21 | 55 | ▶ | use Search::Elasticsearch::Util qw(parse_params load_plugin); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 22 | 55 | ▶ | use namespace::clean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 23 | |||
| 24 | 55 | has 'cxn_class' => ( is => 'ro', required => 1 ); | |
| 25 | 55 | has '_factory' => ( is => 'ro', required => 1 ); | |
| 26 | 55 | has 'default_host' => ( is => 'ro', default => 'http://localhost:9200' ); | |
| 27 | 55 | has 'max_content_length' => ( is => 'rw', default => 104_857_600 ); | |
| 28 | |||
| 29 | #=================================== | ||
| 30 | 100 | ▶ | sub BUILDARGS { |
|
Subroutine
BUILDARGS: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 31 | #=================================== | ||
| 32 | 100 | my ( $class, $params ) = parse_params(@_); | |
| 33 | 100 | my %args = (%$params); | |
| 34 | 100 | delete $args{nodes}; | |
| 35 | |||
| 36 | my $cxn_class | ||
| 37 | 100 | = load_plugin( 'Search::Elasticsearch::Cxn', delete $args{cxn} ); | |
| 38 | 175 | ▶ | $params->{_factory} = sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 39 | 175 | my ( $self, $node ) = @_; | |
| 40 | 175 | $cxn_class->new( | |
| 41 | %args, | ||
| 42 | node => $node, | ||
| 43 | max_content_length => $self->max_content_length | ||
| 44 | ); | ||
| 45 | 100 | }; | |
| 46 | 100 | $params->{cxn_args} = \%args; | |
| 47 | 100 | $params->{cxn_class} = $cxn_class; | |
| 48 | 100 | return $params; | |
| 49 | } | ||
| 50 | |||
| 51 | #=================================== | ||
| 52 | 175 | ▶ | sub new_cxn { shift->_factory->(@_) } |
|
Subroutine
new_cxn: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 53 | #=================================== | ||
| 54 | |||
| 55 | 55 | 1; | |
| 56 | |||
| 57 | =pod | ||
| 58 | |||
| 59 | =encoding UTF-8 | ||
| 60 | |||
| 61 | =head1 NAME | ||
| 62 | |||
| 63 | Search::Elasticsearch::Cxn::Factory - Used by CxnPools to create new Cxn instances. | ||
| 64 | |||
| 65 | =head1 VERSION | ||
| 66 | |||
| 67 | version 8.12 | ||
| 68 | |||
| 69 | =head1 DESCRIPTION | ||
| 70 | |||
| 71 | This class is used by the L<Search::Elasticsearch::Role::CxnPool> implementations | ||
| 72 | to create new L<Search::Elasticsearch::Role::Cxn>-based instances. It holds on | ||
| 73 | to all the configuration options passed to L<Elasticsearch/new()> so | ||
| 74 | that new Cxns can use them. | ||
| 75 | |||
| 76 | It contains no user serviceable parts. | ||
| 77 | |||
| 78 | =head1 AUTHOR | ||
| 79 | |||
| 80 | Enrico Zimuel <enrico.zimuel@elastic.co> | ||
| 81 | |||
| 82 | =head1 COPYRIGHT AND LICENSE | ||
| 83 | |||
| 84 | This software is Copyright (c) 2024 by Elasticsearch BV. | ||
| 85 | |||
| 86 | This is free software, licensed under: | ||
| 87 | |||
| 88 | The Apache License, Version 2.0, January 2004 | ||
| 89 | |||
| 90 | =cut | ||
| 91 | |||
| 92 | __END__ | ||