| 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::Cxn::Factory; | ||
| 24 | 56 | $OpenSearch::Client::Cxn::Factory::VERSION = '3.007011'; | |
| 25 | 56 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 26 | 56 | ▶ | use OpenSearch::Client::Util qw(parse_params load_plugin); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 27 | 56 | ▶ | use namespace::clean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 28 | |||
| 29 | 56 | has 'cxn_class' => ( is => 'ro', required => 1 ); | |
| 30 | 56 | has '_factory' => ( is => 'ro', required => 1 ); | |
| 31 | 56 | has 'default_host' => ( is => 'ro', default => 'http://localhost:9200' ); | |
| 32 | 56 | has 'max_content_length' => ( is => 'rw', default => 104_857_600 ); | |
| 33 | |||
| 34 | #=================================== | ||
| 35 | 100 | ▶ | sub BUILDARGS { |
|
Subroutine
BUILDARGS: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 36 | #=================================== | ||
| 37 | 100 | my ( $class, $params ) = parse_params(@_); | |
| 38 | 100 | my %args = (%$params); | |
| 39 | 100 | delete $args{nodes}; | |
| 40 | |||
| 41 | my $cxn_class | ||
| 42 | 100 | = load_plugin( 'OpenSearch::Client::Cxn', delete $args{cxn} ); | |
| 43 | 175 | ▶ | $params->{_factory} = sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 44 | 175 | my ( $self, $node ) = @_; | |
| 45 | 175 | $cxn_class->new( | |
| 46 | %args, | ||
| 47 | node => $node, | ||
| 48 | max_content_length => $self->max_content_length | ||
| 49 | ); | ||
| 50 | 100 | }; | |
| 51 | 100 | $params->{cxn_args} = \%args; | |
| 52 | 100 | $params->{cxn_class} = $cxn_class; | |
| 53 | 100 | return $params; | |
| 54 | } | ||
| 55 | |||
| 56 | #=================================== | ||
| 57 | 175 | ▶ | sub new_cxn { shift->_factory->(@_) } |
|
Subroutine
new_cxn: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 58 | #=================================== | ||
| 59 | |||
| 60 | 56 | 1; | |
| 61 | |||
| 62 | __END__ | ||