Retry/Strategy/Fibonacci.pm

filter: Statementstmt 91.6% 22 / 24 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 6 / 8 Podpod 0.0% 0 / 3 totaltotal 80.0% 28 / 35 CC 1 SCAR 2.0
CC
1
Cov
92%
__ANON__
2.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.2
« Retry/Strategy/HelperRole/RetriesLimit.pm ↑ Summary Retry/Strategy/Constant.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::Fibonacci;
10 {
11 55 $Action::Retry::Strategy::Fibonacci::VERSION = '0.24';
12 }
13  
14 # ABSTRACT: Fibonacci incrementation of sleep time strategy
15  
16 3 ▶use Math::Fibonacci qw(term);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20  
21  
22 55 with 'Action::Retry::Strategy';
23 60 with 'Action::Retry::Strategy::HelperRole::RetriesLimit';
24 3 with 'Action::Retry::Strategy::HelperRole::SleepTimeout';
25  
26  
27 has initial_term_index => (
28 is => 'ro',
29 lazy => 1,
30 0 ▶ default => sub { 0 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
31 3 );
32  
33 # the current sequence term index
34 has _current_term_index => (
35 is => 'rw',
36 lazy => 1,
37 7 ▶ default => sub { $_[0]->initial_term_index },
Subroutine __ANON__: called CC=1 SCAR=0.0
38 3 init_arg => undef,
39 clearer => 1,
40 );
41  
42  
43  
44 has multiplicator => (
45 is => 'ro',
46 lazy => 1,
47 0 ▶ default => sub { 1000 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
48 3 );
49  
50 61 ▶sub reset {
Subroutine reset: called CC=1 SCAR=0.0
Pod undocumented
51 9 my ($self) = @_;
52 9 $self->_clear_current_term_index;
53 9 return;
54 }
55  
56 83 ▶sub compute_sleep_time {
Subroutine compute_sleep_time: called CC=1 SCAR=0.0
Pod undocumented
57 83 my ($self) = @_;
58 # print STDERR " -- sleep time is " . term($self->_current_term_index) * $self->multiplicator . "\n";
59 83 return term($self->_current_term_index) * $self->multiplicator;
60 }
61  
62 59 ▶sub next_step {
Subroutine next_step: called CC=1 SCAR=0.0
Pod undocumented
63 2 my ($self) = @_;
64 $self->_current_term_index($self->_current_term_index + 1);
65 return;
66 }
67  
68 sub needs_to_retry { 1 }
69  
70 # Inherited from Action::Retry::Strategy::HelperRole::RetriesLimit
71  
72  
73 # Inherited from Action::Retry::Strategy::HelperRole::SleepTimeout
74  
75  
76 3 1;
77  
78 __END__
« Retry/Strategy/HelperRole/RetriesLimit.pm ↑ Summary Retry/Strategy/Constant.pm »