Retry/Strategy/HelperRole/SleepTimeout.pm

filter: Statementstmt 100% 13 / 13 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 95.0% 19 / 20 CC 3 SCAR 7.9
CC
3
Cov
94%
__ANON__
3.0
BEGIN
1.0
__ANON__
1.0
CRAP 2.2
« Retry/Strategy/HelperRole/SleepCapping.pm ↑ Summary Retry/Strategy/HelperRole/RetriesLimit.pm »
1 #
2 # This file is part of Action-Retry
3 #
4 # This software is copyright (c) 2013 by Damien "dams" Krotkine.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9 package Action::Retry::Strategy::HelperRole::SleepTimeout;
10 {
11 7 $Action::Retry::Strategy::HelperRole::SleepTimeout::VERSION = '0.24';
12 }
13  
14 # ABSTRACT: Helper to be consumed by Action::Retry Strategies, to enable giving up retrying when the sleep_time is too big
15  
16 7 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 has max_sleep_time => (
19 is => 'ro',
20 lazy => 1,
21 8 ▶ default => sub { undef },
Subroutine __ANON__: called CC=1 SCAR=0.0
22 7 );
23  
24 83 ▶around needs_to_retry => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
25 83 my $orig = shift;
26 83 my $self = shift;
27 83 ▶ defined $self->max_sleep_time
Branch: 1 branch
BranchTrueFalseTotal
defined $self->max_sleep_time or return &$orig($self, @_) 18 65 83
28 or return $orig->($self, @_);
29 18 ▶ $orig->($self, @_) && $self->compute_sleep_time < $self->max_sleep_time
Branch: 1 branch
BranchTrueFalseTotal
&$orig($self, @_) and $self->compute_sleep_time < $self->max_sleep_time 18 0 18
30 7 };
31  
32 7 1;
33  
34 __END__
« Retry/Strategy/HelperRole/SleepCapping.pm ↑ Summary Retry/Strategy/HelperRole/RetriesLimit.pm »