File Coverage

blib/lib/Algorithm/Backoff/LILD.pm
Criterion Covered Total %
statement 18 19 94.7
branch 3 4 75.0
condition n/a
subroutine 5 5 100.0
pod n/a
total 26 28 92.8


line stmt bran cond sub pod time code
1             package Algorithm::Backoff::LILD;
2              
3             our $DATE = '2019-06-18'; # DATE
4             our $VERSION = '0.007'; # VERSION
5              
6 1     1   52918 use strict;
  1         11  
  1         24  
7 1     1   5 use warnings;
  1         1  
  1         24  
8              
9 1     1   333 use parent qw(Algorithm::Backoff);
  1         245  
  1         5  
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_max_delay,
23             %Algorithm::Backoff::attr_min_delay,
24             %Algorithm::Backoff::attr_initial_delay,
25             %Algorithm::Backoff::attr_delay_increment_on_failure,
26             %Algorithm::Backoff::attr_delay_increment_on_success,
27             },
28             result_naked => 1,
29             result => {
30             schema => 'obj*',
31             },
32             };
33              
34             sub _success {
35 4     4   7 my ($self, $timestamp) = @_;
36              
37 4 50       7 unless (defined $self->{_prev_delay}) {
38 0         0 return $self->{_prev_delay} = $self->{initial_delay};
39             }
40              
41 4         8 my $delay = $self->{_prev_delay} + $self->{delay_increment_on_success};
42              
43 4         6 $delay;
44             }
45              
46             sub _failure {
47 5     5   9 my ($self, $timestamp) = @_;
48              
49 5 100       9 unless (defined $self->{_prev_delay}) {
50 1         4 return $self->{_prev_delay} = $self->{initial_delay};
51             }
52              
53 4         8 my $delay = $self->{_prev_delay} + $self->{delay_increment_on_failure};
54              
55 4         8 $delay;
56             }
57              
58             1;
59             # ABSTRACT: Linear Increment, Linear Decrement (LILD) backoff
60              
61             __END__