Backoff/LILD.pm

filter: Statementstmt 96.1% 25 / 26 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 94.2% 33 / 35 CC 3 SCAR 4.7
CC
3
Cov
93%
_success
2.1
_failure
2.0
BEGIN
1.0
CRAP 1.6
« Backoff/Fibonacci.pm ↑ Summary Backoff/LIMD.pm »
1 package Algorithm::Backoff::LILD;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use parent qw(Algorithm::Backoff);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
9 2 our $DATE = '2024-02-24'; # DATE
10 2 our $DIST = 'Algorithm-Backoff'; # DIST
11 2 our $VERSION = '0.010'; # VERSION
12  
13 2 our %SPEC;
14  
15 $SPEC{new} = {
16 2 v => 1.1,
17 is_class_meth => 1,
18 is_func => 0,
19 args => {
20 %Algorithm::Backoff::attr_consider_actual_delay,
21 %Algorithm::Backoff::attr_max_actual_duration,
22 %Algorithm::Backoff::attr_max_attempts,
23 %Algorithm::Backoff::attr_jitter_factor,
24 %Algorithm::Backoff::attr_max_delay,
25 %Algorithm::Backoff::attr_min_delay,
26 %Algorithm::Backoff::attr_initial_delay,
27 %Algorithm::Backoff::attr_delay_increment_on_failure,
28 %Algorithm::Backoff::attr_delay_increment_on_success,
29 },
30 result_naked => 1,
31 result => {
32 schema => 'obj*',
33 },
34 };
35  
36 4 ▶sub _success {
Subroutine _success: called CC=2 SCAR=7.4
37 4 my ($self, $timestamp) = @_;
38  
39 4 ▶ unless (defined $self->{_prev_delay}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"_prev_delay"}) 0 4 4
40 0 return $self->{_prev_delay} = $self->{initial_delay};
41 }
42  
43 4 my $delay = $self->{_prev_delay} + $self->{delay_increment_on_success};
44  
45 4 $delay;
46 }
47  
48 5 ▶sub _failure {
Subroutine _failure: called CC=2 SCAR=6.9
49 5 my ($self, $timestamp) = @_;
50  
51 5 ▶ unless (defined $self->{_prev_delay}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"_prev_delay"}) 1 4 5
52 1 return $self->{_prev_delay} = $self->{initial_delay};
53 }
54  
55 4 my $delay = $self->{_prev_delay} + $self->{delay_increment_on_failure};
56  
57 4 $delay;
58 }
59  
60 2 1;
61 # ABSTRACT: Linear Increment, Linear Decrement (LILD) backoff
62  
63 __END__
« Backoff/Fibonacci.pm ↑ Summary Backoff/LIMD.pm »