Client.pm

filter: Statementstmt 90.6% 29 / 32 Branchbran 50.0% 2 / 4 Conditioncond 69.2% 9 / 13 MC/DCmcdc 42.8% 3 / 7 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 77.0% 47 / 61 CC 10 SCAR 22.1
CC
10
Cov
82%
new
11.6
BEGIN
1.0
BEGIN
1.0
CRAP 9.1
« Client/Core/3_0/Helper/Scroll.pm ↑ Summary Client/Role/CxnPool/Sniff.pm »
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 61 ▶use Moo 2.001000 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 61 ▶use OpenSearch::Client::Util qw(parse_params load_plugin);
Subroutine BEGIN: called CC=1 SCAR=0.0
27 61 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 61 our $VERSION = '3.007011';
30  
31 61 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 61 my @Load_Order = qw(
41 serializer
42 logger
43 cxn_factory
44 cxn_pool
45 transport
46 client
47 );
48  
49 #===================================
50 100 ▶sub new {
Subroutine new: called CC=10 SCAR=24.5
Pod undocumented
51 #===================================
52 100 my ( $class, $params ) = parse_params(@_);
53  
54 100 ▶ $params->{cxn} ||= 'HTTPTiny';
Condition100%2/2
$params->{"cxn"} ||= "HTTPTiny"
l!l
3268
MC/DC100%1/1
$params->{"cxn"} ||= "HTTPTiny"
$params->{"cxn"}
Truth table100%2/2
A
A= $params->{"cxn"}
Aresult
11
00
55 100 ▶ my $plugins = delete $params->{plugins} || [];
Condition50%1/2
delete $params->{'plugins'} || []
l!l
0100
MC/DC0%0/1
delete $params->{'plugins'} || []
delete $params->{'plugins'}
Truth table50%1/2
A
A= delete $params->{'plugins'}
Aresult
11
00
56 100 ▶ $plugins = [$plugins] unless ref $plugins eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $plugins eq "ARRAY" 0 100 100
57
58 {
59 100 my $username = delete $params->{username};
60 100 my $password = delete $params->{password};
61 100 ▶ if (!$params->{userinfo} && $username && $password) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $params->{"userinfo"} and $username and $password) 0 100 100
Condition50%3/6
not $params->{"userinfo"} and $username and $password
!ll&&!rl&&r
10000
not $params->{"userinfo"} and $username
!ll&&!rl&&r
2980
MC/DC0%0/3
not $params->{"userinfo"} and $username and $password
not $params->{"userinfo"} $username $password
Truth table50%2/4
not(A) and B and C
A= not $params->{"userinfo"}B= $usernameC= $password
ABCresult
0XX0
10X0
1100
1111
62 0 $params->{userinfo} = sprintf('%s:%s', $username , $password );
63 }
64 }
65
66 100 for my $name (@Load_Order) {
67 600 my ( $base, $default ) = @{ $Default_Plugins{$name} };
68 600 ▶ my $sub_class = $params->{$name} || $default;
Condition100%3/3
$params->{$name} || $default
l!l&&r!l&&!r
42358200
MC/DC100%2/2
$params->{$name} || $default
$params->{$name} $default
Truth table100%3/3
A || B
A= $params->{$name}B= $default
ABresult
1X1
011
000
69 600 my $plugin_class = load_plugin( $base, $sub_class );
70 600 $params->{$name} = $plugin_class->new($params);
71 }
72  
73 100 for my $name (@$plugins) {
74 0 my $plugin_class
75 = load_plugin( 'OpenSearch::Client::Plugin', $name );
76 0 $plugin_class->_init_plugin($params);
77 }
78  
79 100 return $params->{client};
80 }
81  
82 61 1;
83  
84 __END__
« Client/Core/3_0/Helper/Scroll.pm ↑ Summary Client/Role/CxnPool/Sniff.pm »