line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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::Linear; |
10
|
|
|
|
|
|
|
{ |
11
|
|
|
|
|
|
|
$Action::Retry::Strategy::Linear::VERSION = '0.24'; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# ABSTRACT: Linear incrementation of sleep time strategy |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
2
|
|
1643
|
use Moo; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
14
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
with 'Action::Retry::Strategy'; |
20
|
|
|
|
|
|
|
with 'Action::Retry::Strategy::HelperRole::RetriesLimit'; |
21
|
|
|
|
|
|
|
with 'Action::Retry::Strategy::HelperRole::SleepTimeout'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has initial_sleep_time => ( |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
lazy => 1, |
27
|
|
|
|
|
|
|
default => sub { 1000 }, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# the current sleep time, as it's computed |
31
|
|
|
|
|
|
|
has _current_sleep_time => ( |
32
|
|
|
|
|
|
|
is => 'rw', |
33
|
|
|
|
|
|
|
lazy => 1, |
34
|
|
|
|
|
|
|
default => sub { $_[0]->initial_sleep_time }, |
35
|
|
|
|
|
|
|
init_arg => undef, |
36
|
|
|
|
|
|
|
clearer => 1, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has multiplicator => ( |
41
|
|
|
|
|
|
|
is => 'ro', |
42
|
|
|
|
|
|
|
lazy => 1, |
43
|
|
|
|
|
|
|
default => sub { 2 }, |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub reset { |
47
|
|
|
|
|
|
|
my ($self) = @_; |
48
|
|
|
|
|
|
|
$self->_clear_current_sleep_time; |
49
|
|
|
|
|
|
|
return; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub compute_sleep_time { |
53
|
22
|
|
|
22
|
0
|
38
|
my ($self) = @_; |
54
|
22
|
|
|
|
|
393
|
return $self->_current_sleep_time; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub next_step { |
58
|
|
|
|
|
|
|
my ($self) = @_; |
59
|
|
|
|
|
|
|
$self->_current_sleep_time($self->_current_sleep_time * $self->multiplicator); |
60
|
|
|
|
|
|
|
return; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub needs_to_retry { 1 } |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Inherited from Action::Retry::Strategy::HelperRole::RetriesLimit |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Inherited from Action::Retry::Strategy::HelperRole::SleepTimeout |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |