| 1 | # OpenSearch::Client is an unofficial client for OpenSearch. | ||||||||||||||||||||
| 2 | # It is derived from Search::Elasticsearch version 7.714 | ||||||||||||||||||||
| 3 | # License details from that work are contained in the NOTICE | ||||||||||||||||||||
| 4 | # file distributed with this work. | ||||||||||||||||||||
| 5 | #----------------------------------------------------------------------- | ||||||||||||||||||||
| 6 | # OpenSearch::Client | ||||||||||||||||||||
| 7 | #----------------------------------------------------------------------- | ||||||||||||||||||||
| 8 | # Copyright 2026 Mark Dootson | ||||||||||||||||||||
| 9 | # | ||||||||||||||||||||
| 10 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||||||||||||
| 11 | # you may not use this file except in compliance with the License. | ||||||||||||||||||||
| 12 | # You may obtain a copy of the License at | ||||||||||||||||||||
| 13 | # | ||||||||||||||||||||
| 14 | # http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||||||
| 15 | # | ||||||||||||||||||||
| 16 | # Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||||
| 17 | # distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||||
| 18 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||||||||
| 19 | # See the License for the specific language governing permissions and | ||||||||||||||||||||
| 20 | # limitations under the License. | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | package OpenSearch::Client; | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 60 | ▶ | use Moo 2.001000 (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 60 | ▶ | use OpenSearch::Client::Util qw(parse_params load_plugin); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 27 | 60 | ▶ | use namespace::clean; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 60 | our $VERSION = '3.007006'; | |||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 60 | my %Default_Plugins = ( | |||||||||||||||||||
| 32 | client => [ 'OpenSearch::Client::Core', '3_0::Direct' ], | ||||||||||||||||||||
| 33 | cxn_factory => [ 'OpenSearch::Client::Cxn::Factory', '' ], | ||||||||||||||||||||
| 34 | cxn_pool => [ 'OpenSearch::Client::CxnPool', 'Static' ], | ||||||||||||||||||||
| 35 | logger => [ 'OpenSearch::Client::Logger', 'LogAny' ], | ||||||||||||||||||||
| 36 | serializer => [ 'OpenSearch::Client::Serializer', 'JSON' ], | ||||||||||||||||||||
| 37 | transport => [ 'OpenSearch::Client::Transport', '' ], | ||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 60 | my @Load_Order = qw( | |||||||||||||||||||
| 41 | serializer | ||||||||||||||||||||
| 42 | logger | ||||||||||||||||||||
| 43 | cxn_factory | ||||||||||||||||||||
| 44 | cxn_pool | ||||||||||||||||||||
| 45 | transport | ||||||||||||||||||||
| 46 | client | ||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | #=================================== | ||||||||||||||||||||
| 50 | sub new { | ||||||||||||||||||||
| 51 | #=================================== | ||||||||||||||||||||
| 52 | 100 | ▶ | my ( $class, $params ) = parse_params(@_); | ||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=19.8
Pod
undocumented
| |||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 100 | ▶ | $params->{cxn} ||= 'HTTPTiny'; | ||||||||||||||||||
|
Condition100%2/2
$params->{"cxn"} ||= "HTTPTiny"
MC/DC100%1/1
$params->{"cxn"} ||= "HTTPTiny"
$params->{"cxn"}
Truth table100%2/2
A
A= $params->{"cxn"}
| |||||||||||||||||||||
| 55 | 100 | ▶ | my $plugins = delete $params->{plugins} || []; | ||||||||||||||||||
|
Condition50%1/2
delete $params->{'plugins'} || []
MC/DC0%0/1
delete $params->{'plugins'} || []
delete $params->{'plugins'}
Truth table50%1/2
A
A= delete $params->{'plugins'}
| |||||||||||||||||||||
| 56 | 100 | ▶ | $plugins = [$plugins] unless ref $plugins eq 'ARRAY'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 100 | for my $name (@Load_Order) { | |||||||||||||||||||
| 59 | 600 | my ( $base, $default ) = @{ $Default_Plugins{$name} }; | |||||||||||||||||||
| 60 | 600 | ▶ | my $sub_class = $params->{$name} || $default; | ||||||||||||||||||
|
Condition100%3/3
$params->{$name} || $default
MC/DC100%2/2
$params->{$name} || $default
$params->{$name}
$default
Truth table100%3/3
A || B
A= $params->{$name}B= $default
| |||||||||||||||||||||
| 61 | 600 | my $plugin_class = load_plugin( $base, $sub_class ); | |||||||||||||||||||
| 62 | 600 | $params->{$name} = $plugin_class->new($params); | |||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 100 | for my $name (@$plugins) { | |||||||||||||||||||
| 66 | 0 | my $plugin_class | |||||||||||||||||||
| 67 | = load_plugin( 'OpenSearch::Client::Plugin', $name ); | ||||||||||||||||||||
| 68 | 0 | $plugin_class->_init_plugin($params); | |||||||||||||||||||
| 69 | } | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 100 | return $params->{client}; | |||||||||||||||||||
| 72 | } | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 60 | 1; | |||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | __END__ | ||||||||||||||||||||