| 1 | package DBIx::TryAgain::st; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | our @ISA = 'DBI::st'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 12 | ▶ | sub _should_try_again { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_should_try_again: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 12 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 12 | ▶ | my $tried = $self->{private_dbix_try_again_tries} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'private_dbix_try_again_tries'} || 0
MC/DC100%1/1
$self->{'private_dbix_try_again_tries'} || 0
$self->{'private_dbix_try_again_tries'}
Truth table100%2/2
A
A= $self->{'private_dbix_try_again_tries'}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 12 | ▶ | return 0 if $tried >= $self->{private_dbix_try_again_max_retries}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 9 | for my $msg ( @{ $self->{private_dbix_try_again_on_messages} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 9 | ▶ | if ($self->errstr =~ $msg) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 9 | DBI->trace_msg("DBIx::TryAgain [$$] error string ".$self->errstr." matches $msg, will try again.\n"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 9 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 12 | ▶ | sub _sleep { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sleep: called CC=11 SCAR=24.5
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 12 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 12 | my $init = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 12 | ▶ | if ($init) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | $self->{private_dbix_try_again_tries} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 3 | $self->{private_dbix_try_again_slept} = []; | |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 9 | my $tried = $self->{private_dbix_try_again_tries}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 9 | my $slept = $self->{private_dbix_try_again_slept}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 9 | my $alg = $self->{private_dbix_try_again_algorithm}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 9 | ▶ | my $delay = | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
Condition66%2/3
$tried == 2 and $alg eq "fibonacci"
MC/DC50%1/2
$tried == 2 and $alg eq "fibonacci"
$tried == 2
$alg eq "fibonacci"
Truth table66%2/3
A and B
A= $tried == 2B= $alg eq "fibonacci"
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | $tried == 1 ? 1 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | : $tried == 2 && $alg eq 'fibonacci' ? 1 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | : $alg eq 'constant' ? $slept->[-1] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | : $alg eq 'linear' ? $slept->[-1] + 1 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | : $alg eq 'exponential' ? $slept->[-1] * 2 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | : $alg eq 'fibonacci' ? $slept->[-1] + $slept->[-2] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | : die "unknown backoff algorithm : $alg"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 9 | push @$slept, $delay; | |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 9 | for ("DBIx::TryAgain [$$] sleeping $delay") { | |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 9 | DBI->trace_msg($_); | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 9 | ▶ | warn $_ if $self->{PrintError}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 9 | sleep $delay; | |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 9 | return; | |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 2 | ▶ | sub execute { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 2 | my $res = $self->SUPER::execute(@_); | |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 2 | ▶ | return $res if $res; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | $self->_sleep('init'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | $self->{private_dbix_try_again_tries} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | ▶ | while ($self->_should_try_again) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 3 | $self->{private_dbix_try_again_tries}++; | |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 3 | for ("DBIx::TryAgain [$$] execute attempt number ".$self->{private_dbix_try_again_tries}."\n") { | |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 3 | DBI->trace_msg($_); | |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 3 | ▶ | warn $_ if $self->{PrintError}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 3 | $self->_sleep; | |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 3 | $self->set_err(undef, undef); | |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 3 | $res = $self->SUPER::execute(@_); | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 3 | ▶ | return $res if $res; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||