Elasticsearch/Cxn/Factory.pm

filter: Statementstmt 100% 27 / 27 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 94.2% 33 / 35 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Elasticsearch/Role/Client.pm ↑ Summary Elasticsearch/CxnPool/Static/NoPing.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::Cxn::Factory;
6 55 $Search::Elasticsearch::Cxn::Factory::VERSION = '7.30_1'; # TRIAL
7  
8 55 $Search::Elasticsearch::Cxn::Factory::VERSION = '7.301';
9 55 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 55 ▶use Search::Elasticsearch::Util qw(parse_params load_plugin);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 55 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 55 has 'cxn_class' => ( is => 'ro', required => 1 );
14 55 has '_factory' => ( is => 'ro', required => 1 );
15 55 has 'default_host' => ( is => 'ro', default => 'http://localhost:9200' );
16 55 has 'max_content_length' => ( is => 'rw', default => 104_857_600 );
17  
18 #===================================
19 sub BUILDARGS {
20 #===================================
21 100 ▶ my ( $class, $params ) = parse_params(@_);
Subroutine BUILDARGS: called CC=1 SCAR=0.0
Pod undocumented
22 100 my %args = (%$params);
23 100 delete $args{nodes};
24  
25 my $cxn_class
26 100 = load_plugin( 'Search::Elasticsearch::Cxn', delete $args{cxn} );
27 $params->{_factory} = sub {
28 175 ▶ my ( $self, $node ) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
29 175 $cxn_class->new(
30 %args,
31 node => $node,
32 max_content_length => $self->max_content_length
33 );
34 100 };
35 100 $params->{cxn_args} = \%args;
36 100 $params->{cxn_class} = $cxn_class;
37 100 return $params;
38 }
39  
40 #===================================
41 175 ▶sub new_cxn { shift->_factory->(@_) }
Subroutine new_cxn: called CC=1 SCAR=0.0
Pod undocumented
42 #===================================
43  
44 55 1;
45  
46 =pod
47  
48 =encoding UTF-8
49  
50 =head1 NAME
51  
52 Search::Elasticsearch::Cxn::Factory - Used by CxnPools to create new Cxn instances.
53  
54 =head1 VERSION
55  
56 version 7.30_1
57  
58 =head1 DESCRIPTION
59  
60 This class is used by the L<Search::Elasticsearch::Role::CxnPool> implementations
61 to create new L<Search::Elasticsearch::Role::Cxn>-based instances. It holds on
62 to all the configuration options passed to L<Elasticsearch/new()> so
63 that new Cxns can use them.
64  
65 It contains no user serviceable parts.
66  
67 =head1 AUTHOR
68  
69 Enrico Zimuel <enrico.zimuel@elastic.co>
70  
71 =head1 COPYRIGHT AND LICENSE
72  
73 This software is Copyright (c) 2020 by Elasticsearch BV.
74  
75 This is free software, licensed under:
76  
77 The Apache License, Version 2.0, January 2004
78  
79 =cut
80  
81 __END__
« Elasticsearch/Role/Client.pm ↑ Summary Elasticsearch/CxnPool/Static/NoPing.pm »