line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Algorithm::Backoff::Exponential; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2019-06-18'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.007'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
53814
|
use strict; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
25
|
|
7
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
341
|
use parent qw(Algorithm::Backoff); |
|
1
|
|
|
|
|
256
|
|
|
1
|
|
|
|
|
4
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our %SPEC; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$SPEC{new} = { |
14
|
|
|
|
|
|
|
v => 1.1, |
15
|
|
|
|
|
|
|
is_class_meth => 1, |
16
|
|
|
|
|
|
|
is_func => 0, |
17
|
|
|
|
|
|
|
args => { |
18
|
|
|
|
|
|
|
%Algorithm::Backoff::attr_consider_actual_delay, |
19
|
|
|
|
|
|
|
%Algorithm::Backoff::attr_max_actual_duration, |
20
|
|
|
|
|
|
|
%Algorithm::Backoff::attr_max_attempts, |
21
|
|
|
|
|
|
|
%Algorithm::Backoff::attr_jitter_factor, |
22
|
|
|
|
|
|
|
%Algorithm::Backoff::attr_delay_on_success, |
23
|
|
|
|
|
|
|
%Algorithm::Backoff::attr_min_delay, |
24
|
|
|
|
|
|
|
%Algorithm::Backoff::attr_max_delay, |
25
|
|
|
|
|
|
|
%Algorithm::Backoff::attr_initial_delay, |
26
|
|
|
|
|
|
|
exponent_base => { |
27
|
|
|
|
|
|
|
schema => 'ufloat*', |
28
|
|
|
|
|
|
|
default => 2, |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
result_naked => 1, |
32
|
|
|
|
|
|
|
result => { |
33
|
|
|
|
|
|
|
schema => 'obj*', |
34
|
|
|
|
|
|
|
}, |
35
|
|
|
|
|
|
|
}; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _success { |
38
|
1
|
|
|
1
|
|
3
|
my ($self, $timestamp) = @_; |
39
|
1
|
|
|
|
|
3
|
$self->{delay_on_success}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _failure { |
43
|
9
|
|
|
9
|
|
15
|
my ($self, $timestamp) = @_; |
44
|
|
|
|
|
|
|
my $delay = $self->{initial_delay} * |
45
|
9
|
|
|
|
|
29
|
$self->{exponent_base} ** ($self->{_attempts}-1); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
# ABSTRACT: Backoff exponentially |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |