Elasticsearch/Cxn/Factory.pm

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