Backoff/Exponential.pm

filter: Statementstmt 100% 20 / 20 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 100% 25 / 25 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Backoff/Constant.pm ↑ Summary
1 package Algorithm::Backoff::Exponential;
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_delay_on_success,
25 %Algorithm::Backoff::attr_min_delay,
26 %Algorithm::Backoff::attr_max_delay,
27 %Algorithm::Backoff::attr_initial_delay,
28 exponent_base => {
29 schema => 'ufloat*',
30 default => 2,
31 },
32 },
33 result_naked => 1,
34 result => {
35 schema => 'obj*',
36 },
37 };
38  
39 1 ▶sub _success {
Subroutine _success: called CC=1 SCAR=0.0
40 1 my ($self, $timestamp) = @_;
41 1 $self->{delay_on_success};
42 }
43  
44 9 ▶sub _failure {
Subroutine _failure: called CC=1 SCAR=0.0
45 9 my ($self, $timestamp) = @_;
46 my $delay = $self->{initial_delay} *
47 9 $self->{exponent_base} ** ($self->{_attempts}-1);
48 }
49  
50 2 1;
51 # ABSTRACT: Backoff exponentially
52  
53 __END__
« Backoff/Constant.pm ↑ Summary