Elasticsearch/Role/Transport.pm

filter: Statementstmt 100% 41 / 41 Branchbran 90.0% 9 / 10 Conditioncond 92.3% 12 / 13 MC/DCmcdc 71.4% 5 / 7 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 92.4% 73 / 79 CC 12 SCAR 21.7
CC
12
Cov
97%
tidy_request
12.0
BEGIN
1.0
BEGIN
1.0
CRAP 8.8
« Elasticsearch/Client/8_0/Scroll.pm ↑ Summary Elasticsearch/Role/CxnPool/Sniff.pm »
1 # Licensed to Elasticsearch B.V under one or more agreements.
2 # Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3 # See the LICENSE file in the project root for more information
4  
5 package Search::Elasticsearch::Role::Transport;
6 55 $Search::Elasticsearch::Role::Transport::VERSION = '8.12';
7 55 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 55 requires qw(perform_request);
10  
11 55 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 55 ▶use Search::Elasticsearch::Util qw(parse_params is_compat);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 55 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 55 has 'serializer' => ( is => 'ro', required => 1 );
16 55 has 'logger' => ( is => 'ro', required => 1 );
17 55 has 'send_get_body_as' => ( is => 'ro', default => 'GET' );
18 55 has 'cxn_pool' => ( is => 'ro', required => 1 );
19  
20 #===================================
21 100 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
22 #===================================
23 100 my $self = shift;
24 100 my $pool = $self->cxn_pool;
25 100 is_compat( 'cxn_pool', $self, $pool );
26 100 is_compat( 'cxn', $self, $pool->cxn_factory->cxn_class );
27 100 return $self;
28 }
29  
30 #===================================
31 175 ▶sub tidy_request {
Subroutine tidy_request: called CC=12 SCAR=24.9
Pod undocumented
32 #===================================
33 175 my ( $self, $params ) = parse_params(@_);
34 175 ▶ $params->{method} ||= 'GET';
Condition100%2/2
$params->{"method"} ||= "GET"
l!l
20155
MC/DC100%1/1
$params->{"method"} ||= "GET"
$params->{"method"}
Truth table100%2/2
A
A= $params->{"method"}
Aresult
11
00
35 175 ▶ $params->{path} ||= '/';
Condition100%2/2
$params->{"path"} ||= "/"
l!l
26149
MC/DC100%1/1
$params->{"path"} ||= "/"
$params->{"path"}
Truth table100%2/2
A
A= $params->{"path"}
Aresult
11
00
36 175 ▶ $params->{qs} ||= {};
Condition100%2/2
$params->{"qs"} ||= {}
l!l
20155
MC/DC100%1/1
$params->{"qs"} ||= {}
$params->{"qs"}
Truth table100%2/2
A
A= $params->{"qs"}
Aresult
11
00
37 175 ▶ $params->{ignore} ||= [];
Condition100%2/2
$params->{"ignore"} ||= []
l!l
19156
MC/DC100%1/1
$params->{"ignore"} ||= []
$params->{"ignore"}
Truth table100%2/2
A
A= $params->{"ignore"}
Aresult
11
00
38 175 my $body = $params->{body};
39 175 ▶ return $params unless defined $body;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $body 167 8 175
40  
41 8 ▶ $params->{serialize} ||= 'std';
Condition100%2/2
$params->{"serialize"} ||= "std"
l!l
17
MC/DC100%1/1
$params->{"serialize"} ||= "std"
$params->{"serialize"}
Truth table100%2/2
A
A= $params->{"serialize"}
Aresult
11
00
42 $params->{data}
43 8 ▶ = $params->{serialize} eq 'std'
Branch: 1 branch
BranchTrueFalseTotal
$params->{'serialize'} eq 'std' ? : 7 1 8
44 ? $self->serializer->encode($body)
45 : $self->serializer->encode_bulk($body);
46  
47 8 ▶ if ( $params->{method} eq 'GET' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"method"} eq "GET") 8 0 8
48 8 my $send_as = $self->send_get_body_as;
49 8 ▶ if ( $send_as eq 'POST' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($send_as eq 'POST') { } 1 7 8
elsif ($send_as eq 'source') { } 1 6 7
50 1 $params->{method} = 'POST';
51 }
52 elsif ( $send_as eq 'source' ) {
53 1 $params->{qs}{source} = delete $params->{data};
54 1 delete $params->{body};
55 }
56 }
57  
58 8 ▶ $params->{mime_type} ||= $self->serializer->mime_type;
Condition66%2/3
$params->{"mime_type"} ||= $self->serializer->mime_type
l!l&&r!l&&!r
170
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
ABresult
1X1
011
000
59 8 return $params;
60  
61 }
62  
63 55 1;
64  
65 #ABSTRACT: Transport role providing interface between the client class and the Elasticsearch cluster
66  
67 __END__
« Elasticsearch/Client/8_0/Scroll.pm ↑ Summary Elasticsearch/Role/CxnPool/Sniff.pm »