Elasticsearch/Transport.pm

filter: Statementstmt 100% 42 / 42 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 100% 58 / 58 CC 4 SCAR 6.9
CC
4
Cov
100%
perform_request
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« Elasticsearch/Role/CxnPool/Static.pm ↑ Summary Elasticsearch/Logger/LogAny.pm »
1 package Search::Elasticsearch::Transport;
2 55 $Search::Elasticsearch::Transport::VERSION = '6.80';
3 55 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 55 ▶use URI();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 55 ▶use Time::HiRes qw(time);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 55 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 55 ▶use Search::Elasticsearch::Util qw(upgrade_error);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 55 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 55 with 'Search::Elasticsearch::Role::Is_Sync',
12 'Search::Elasticsearch::Role::Transport';
13  
14 #===================================
15 sub perform_request {
16 #===================================
17 160 ▶ my $self = shift;
Subroutine perform_request: called CC=4 SCAR=13.9
Pod documented
18 160 my $params = $self->tidy_request(@_);
19 160 my $pool = $self->cxn_pool;
20 160 my $logger = $self->logger;
21  
22 160 my ( $code, $response, $cxn, $error );
23  
24 try {
25 160 ▶ $cxn = $pool->next_cxn;
Subroutine __ANON__: called CC=1 SCAR=0.0
26 148 my $start = time();
27 148 $logger->trace_request( $cxn, $params );
28  
29 148 ( $code, $response ) = $cxn->perform_request($params);
30 114 $pool->request_ok($cxn);
31 114 $logger->trace_response( $cxn, $code, $response, time() - $start );
32 }
33 catch {
34 46 ▶ $error = upgrade_error(
Subroutine __ANON__: called CC=1 SCAR=0.0
35 $_,
36 { request => $params,
37 status_code => $code,
38 body => $response
39 }
40 );
41 160 };
42  
43 160 ▶ if ($error) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 46 114 160
44 46 ▶ if ( $pool->request_failed( $cxn, $error ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pool->request_failed($cxn, $error)) 19 27 46
45 19 $logger->debugf( "[%s] %s", $cxn->stringify, "$error" );
46 19 $logger->info('Retrying request on a new cxn');
47 19 return $self->perform_request($params);
48 }
49  
50 27 $logger->trace_error( $cxn, $error );
51 27 ▶ $error->is('NoNodes')
Branch: 1 branch
BranchTrueFalseTotal
$error->is('NoNodes') ? : 12 15 27
52 ? $logger->throw_critical($error)
53 : $logger->throw_error($error);
54 }
55  
56 114 return $response;
57 }
58  
59 55 1;
60  
61 #ABSTRACT: Provides interface between the client class and the Elasticsearch cluster
62  
63 __END__
« Elasticsearch/Role/CxnPool/Static.pm ↑ Summary Elasticsearch/Logger/LogAny.pm »