| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
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::Transport; |
|
6
|
|
|
|
|
|
|
$Search::Elasticsearch::Transport::VERSION = '8.12'; |
|
7
|
55
|
|
|
55
|
|
43745
|
use Moo; |
|
|
55
|
|
|
|
|
141
|
|
|
|
55
|
|
|
|
|
490
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
55
|
|
|
55
|
|
27284
|
use URI(); |
|
|
55
|
|
|
|
|
157
|
|
|
|
55
|
|
|
|
|
1696
|
|
|
10
|
55
|
|
|
55
|
|
293
|
use Time::HiRes qw(time); |
|
|
55
|
|
|
|
|
140
|
|
|
|
55
|
|
|
|
|
653
|
|
|
11
|
55
|
|
|
55
|
|
4680
|
use Try::Tiny; |
|
|
55
|
|
|
|
|
159
|
|
|
|
55
|
|
|
|
|
3969
|
|
|
12
|
55
|
|
|
55
|
|
379
|
use Search::Elasticsearch::Util qw(upgrade_error); |
|
|
55
|
|
|
|
|
172
|
|
|
|
55
|
|
|
|
|
564
|
|
|
13
|
55
|
|
|
55
|
|
20536
|
use namespace::clean; |
|
|
55
|
|
|
|
|
119
|
|
|
|
55
|
|
|
|
|
6661
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
with 'Search::Elasticsearch::Role::Is_Sync', |
|
16
|
|
|
|
|
|
|
'Search::Elasticsearch::Role::Transport'; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#=================================== |
|
19
|
|
|
|
|
|
|
sub perform_request { |
|
20
|
|
|
|
|
|
|
#=================================== |
|
21
|
160
|
|
|
160
|
1
|
1406
|
my $self = shift; |
|
22
|
160
|
|
|
|
|
612
|
my $params = $self->tidy_request(@_); |
|
23
|
160
|
|
|
|
|
536
|
my $pool = $self->cxn_pool; |
|
24
|
160
|
|
|
|
|
410
|
my $logger = $self->logger; |
|
25
|
|
|
|
|
|
|
|
|
26
|
160
|
|
|
|
|
280
|
my ( $code, $response, $cxn, $error ); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
try { |
|
29
|
160
|
|
|
160
|
|
12507
|
$cxn = $pool->next_cxn; |
|
30
|
148
|
|
|
|
|
1328
|
my $start = time(); |
|
31
|
148
|
|
|
|
|
676
|
$logger->trace_request( $cxn, $params ); |
|
32
|
|
|
|
|
|
|
|
|
33
|
148
|
|
|
|
|
14333
|
( $code, $response ) = $cxn->perform_request($params); |
|
34
|
114
|
|
|
|
|
584
|
$pool->request_ok($cxn); |
|
35
|
114
|
|
|
|
|
828
|
$logger->trace_response( $cxn, $code, $response, time() - $start ); |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
catch { |
|
38
|
46
|
|
|
46
|
|
912
|
$error = upgrade_error( |
|
39
|
|
|
|
|
|
|
$_, |
|
40
|
|
|
|
|
|
|
{ request => $params, |
|
41
|
|
|
|
|
|
|
status_code => $code, |
|
42
|
|
|
|
|
|
|
body => $response |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
); |
|
45
|
160
|
|
|
|
|
1375
|
}; |
|
46
|
|
|
|
|
|
|
|
|
47
|
160
|
100
|
|
|
|
8648
|
if ($error) { |
|
48
|
46
|
100
|
|
|
|
261
|
if ( $pool->request_failed( $cxn, $error ) ) { |
|
49
|
19
|
|
|
|
|
114
|
$logger->debugf( "[%s] %s", $cxn->stringify, "$error" ); |
|
50
|
19
|
|
|
|
|
902
|
$logger->info('Retrying request on a new cxn'); |
|
51
|
19
|
|
|
|
|
628
|
return $self->perform_request($params); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
27
|
|
|
|
|
174
|
$logger->trace_error( $cxn, $error ); |
|
55
|
27
|
100
|
|
|
|
1630
|
$error->is('NoNodes') |
|
56
|
|
|
|
|
|
|
? $logger->throw_critical($error) |
|
57
|
|
|
|
|
|
|
: $logger->throw_error($error); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
114
|
|
|
|
|
908
|
return $response; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
#ABSTRACT: Provides interface between the client class and the Elasticsearch cluster |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |