File Coverage

blib/lib/Elasticsearch/Role/CxnPool/Static/NoPing.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 2 3 66.6
total 24 25 96.0


line stmt bran cond sub pod time code
1             package Elasticsearch::Role::CxnPool::Static::NoPing;
2             $Elasticsearch::Role::CxnPool::Static::NoPing::VERSION = '1.05';
3 7     7   5385 use Moo::Role;
  7         16  
  7         59  
4             with 'Elasticsearch::Role::CxnPool';
5             requires 'next_cxn';
6 7     7   3295 use namespace::clean;
  7         18  
  7         59  
7              
8             has 'max_retries' => ( is => 'lazy' );
9             has '_dead_cxns' => ( is => 'ro', default => sub { [] } );
10              
11             #===================================
12 4     4   2109 sub _build_max_retries { @{ shift->cxns } - 1 }
  4         64  
13 11     11   45 sub _max_retries { shift->max_retries + 1 }
14             #===================================
15              
16             #===================================
17             sub BUILD {
18             #===================================
19 7     7 0 131 my $self = shift;
20 7         15 $self->set_cxns( @{ $self->seed_nodes } );
  7         64  
21             }
22              
23             #===================================
24             sub should_mark_dead {
25             #===================================
26 12     12 1 24 my ( $self, $error ) = @_;
27 12         44 return $error->is( 'Cxn', 'Timeout' );
28             }
29              
30             #===================================
31             after 'reset_retries' => sub {
32             #===================================
33             my $self = shift;
34             @{ $self->_dead_cxns } = ();
35              
36             };
37              
38             #===================================
39 12     12 1 39 sub schedule_check { }
40             #===================================
41              
42             1;
43              
44             # ABSTRACT: A CxnPool for connecting to a remote cluster without the ability to ping.
45              
46             __END__
47              
48             =pod
49              
50             =encoding UTF-8
51              
52             =head1 NAME
53              
54             Elasticsearch::Role::CxnPool::Static::NoPing - A CxnPool for connecting to a remote cluster without the ability to ping.
55              
56             =head1 VERSION
57              
58             version 1.05
59              
60             =head1 CONFIGURATION
61              
62             =head2 C<max_retries>
63              
64             The number of times a request should be retried before throwin an exception.
65             Defaults to the number of nodes minus 1.
66              
67             =head1 METHODS
68              
69             =head2 C<should_mark_dead()>
70              
71             $bool = $cxn_pool->should_mark_dead($error);
72              
73             Connection and timeout errors cause cxns to be marked as dead.
74              
75             =head2 C<schedule_check()>
76              
77             This method is a NOOP.
78              
79             =head1 AUTHOR
80              
81             Clinton Gormley <drtech@cpan.org>
82              
83             =head1 COPYRIGHT AND LICENSE
84              
85             This software is Copyright (c) 2014 by Elasticsearch BV.
86              
87             This is free software, licensed under:
88              
89             The Apache License, Version 2.0, January 2004
90              
91             =cut