| 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::Role::Transport; | ||||||||||||||||||||
| 24 | 56 | $OpenSearch::Client::Role::Transport::VERSION = '3.007011'; | |||||||||||||||||||
| 25 | 56 | ▶ | use Moo::Role; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 56 | requires qw(perform_request); | |||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 56 | ▶ | use Try::Tiny; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 30 | 56 | ▶ | use OpenSearch::Client::Util qw(parse_params is_compat); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 31 | 56 | ▶ | use namespace::clean; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 56 | has 'serializer' => ( is => 'ro', required => 1 ); | |||||||||||||||||||
| 34 | 56 | has 'logger' => ( is => 'ro', required => 1 ); | |||||||||||||||||||
| 35 | 56 | has 'send_body_as_source' => ( is => 'ro', default => 0 ); | |||||||||||||||||||
| 36 | 56 | has 'cxn_pool' => ( is => 'ro', required => 1 ); | |||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | #=================================== | ||||||||||||||||||||
| 39 | 100 | ▶ | sub BUILD { | ||||||||||||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 40 | #=================================== | ||||||||||||||||||||
| 41 | 100 | my $self = shift; | |||||||||||||||||||
| 42 | 100 | my $pool = $self->cxn_pool; | |||||||||||||||||||
| 43 | 100 | is_compat( 'cxn_pool', $self, $pool ); | |||||||||||||||||||
| 44 | 100 | is_compat( 'cxn', $self, $pool->cxn_factory->cxn_class ); | |||||||||||||||||||
| 45 | 100 | return $self; | |||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | #=================================== | ||||||||||||||||||||
| 49 | 175 | ▶ | sub tidy_request { | ||||||||||||||||||
|
Subroutine
tidy_request: called CC=11 SCAR=24.0
Pod
undocumented
| |||||||||||||||||||||
| 50 | #=================================== | ||||||||||||||||||||
| 51 | 175 | my ( $self, $params ) = parse_params(@_); | |||||||||||||||||||
| 52 | 175 | ▶ | $params->{method} ||= 'GET'; | ||||||||||||||||||
|
Condition100%2/2
$params->{"method"} ||= "GET"
MC/DC100%1/1
$params->{"method"} ||= "GET"
$params->{"method"}
Truth table100%2/2
A
A= $params->{"method"}
| |||||||||||||||||||||
| 53 | 175 | ▶ | $params->{path} ||= '/'; | ||||||||||||||||||
|
Condition100%2/2
$params->{"path"} ||= "/"
MC/DC100%1/1
$params->{"path"} ||= "/"
$params->{"path"}
Truth table100%2/2
A
A= $params->{"path"}
| |||||||||||||||||||||
| 54 | 175 | ▶ | $params->{qs} ||= {}; | ||||||||||||||||||
|
Condition100%2/2
$params->{"qs"} ||= {}
MC/DC100%1/1
$params->{"qs"} ||= {}
$params->{"qs"}
Truth table100%2/2
A
A= $params->{"qs"}
| |||||||||||||||||||||
| 55 | 175 | ▶ | $params->{ignore} ||= []; | ||||||||||||||||||
|
Condition100%2/2
$params->{"ignore"} ||= []
MC/DC100%1/1
$params->{"ignore"} ||= []
$params->{"ignore"}
Truth table100%2/2
A
A= $params->{"ignore"}
| |||||||||||||||||||||
| 56 | 175 | my $body = $params->{body}; | |||||||||||||||||||
| 57 | 175 | ▶ | return $params unless defined $body; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 8 | ▶ | $params->{serialize} ||= 'std'; | ||||||||||||||||||
|
Condition100%2/2
$params->{"serialize"} ||= "std"
MC/DC100%1/1
$params->{"serialize"} ||= "std"
$params->{"serialize"}
Truth table100%2/2
A
A= $params->{"serialize"}
| |||||||||||||||||||||
| 60 | $params->{data} | ||||||||||||||||||||
| 61 | 8 | ▶ | = $params->{serialize} eq 'std' | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 62 | ? $self->serializer->encode($body) | ||||||||||||||||||||
| 63 | : $self->serializer->encode_bulk($body); | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 8 | ▶ | if ( $self->send_body_as_source ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 66 | 1 | $params->{qs}{source} = delete $params->{data}; | |||||||||||||||||||
| 67 | 1 | delete $params->{body}; | |||||||||||||||||||
| 68 | } | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | 8 | ▶ | if ( $params->{serialize} eq 'bulk' ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 71 | 1 | $params->{mime_type} = 'application/x-ndjson'; | |||||||||||||||||||
| 72 | } | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 8 | ▶ | $params->{mime_type} ||= $self->serializer->mime_type; | ||||||||||||||||||
|
Condition66%2/3
$params->{"mime_type"} ||= $self->serializer->mime_type
MC/DC0%0/2
$params->{"mime_type"} ||= $self->serializer->mime_type
$params->{"mime_type"}
$self->serializer->mime_type
Truth table66%2/3
A ||= B
A= $params->{"mime_type"}B= $self->serializer->mime_type
| |||||||||||||||||||||
| 75 | 8 | return $params; | |||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | } | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 56 | 1; | |||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | __END__ | ||||||||||||||||||||