Async/Backoff.pm

filter: Statementstmt 84.8% 28 / 33 Branchbran 50.0% 2 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 70.0% 7 / 10 Podpod 0.0% 0 / 7 totaltotal 64.9% 37 / 57 CC 5 SCAR 9.0
CC
5
Cov
77%
next
6.0
instantiate
3.1
initial_delay
2.0
CRAP 2.5
« Async/ORM/Constraint.pm ↑ Summary Async/ORM/Field.pm »
1 package Database::Async::Backoff;
2  
3 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 8 our $VERSION = '0.019'; # VERSION
7  
8 =head1 NAME
9  
10 Database::Async::Backoff - support for backoff algorithms in L<Database::Async>
11  
12 =head1 DESCRIPTION
13  
14 =cut
15  
16 8 ▶use Future::AsyncAwait;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 8 my %class_for_type;
18  
19 6 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
20 6 my ($class, %args) = @_;
21 6 bless \%args, $class
22 }
23  
24 0 ▶sub initial_delay { shift->{initial_delay} }
Subroutine initial_delay: not called CC=1 SCAR=6.9
Pod undocumented
25 0 ▶sub max_delay { shift->{max_delay} }
Subroutine max_delay: not called CC=1 SCAR=6.9
Pod undocumented
26  
27 0 ▶async sub next {
Subroutine next: not called CC=2 SCAR=17.9
Pod undocumented
28 0 my ($self, $code) = @_;
29 0 ▶ return $self->{delay} ||= 1;
Condition0%0/2
$self->{"delay"} ||= 1
l!l
00
MC/DC0%0/1
$self->{"delay"} ||= 1
$self->{"delay"}
Truth table0%0/2
A
A= $self->{"delay"}
Aresult
11
00
30 8 }
31  
32 1 ▶async sub reset {
Subroutine reset: called CC=1 SCAR=0.0
Pod undocumented
33 1 my ($self) = @_;
34 1 $self->{delay} = 0;
35 1 $self
36 8 }
37  
38 12 ▶sub register {
Subroutine register: called CC=2 SCAR=6.9
Pod undocumented
39 12 my ($class, %args) = @_;
40 12 for my $k (keys %args) {
41 12 $class_for_type{$k} = $args{$k}
42 }
43 $class
44 12 }
45  
46 6 ▶sub instantiate {
Subroutine instantiate: called CC=3 SCAR=11.4
Pod undocumented
47 6 my ($class, %args) = @_;
48 my $type = delete $args{type}
49 6 ▶ or die 'backoff type required';
Branch: 1 branch
BranchTrueFalseTotal
my $type = delete $args{"type"} or die "backoff type required" 6 0 6
50 6 ▶ my $target_class = $class_for_type{$type}
Branch: 1 branch
BranchTrueFalseTotal
my $target_class = $class_for_type{$type} or die 'unknown backoff type ' . $type 6 0 6
51 or die 'unknown backoff type ' . $type;
52 6 return $target_class->new(%args);
53 }
54  
55 8 1;
56  
« Async/ORM/Constraint.pm ↑ Summary Async/ORM/Field.pm »