line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
7
|
|
|
7
|
|
93
|
use strict; |
|
7
|
|
|
|
|
20
|
|
|
7
|
|
|
|
|
462
|
|
2
|
7
|
|
|
7
|
|
61
|
use warnings; |
|
7
|
|
|
|
|
20
|
|
|
7
|
|
|
|
|
391
|
|
3
|
7
|
|
|
7
|
|
60
|
use MRO::Compat 'c3'; |
|
7
|
|
|
|
|
19
|
|
|
7
|
|
|
|
|
441
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package WebService::Shippo::Async; |
6
|
7
|
|
|
7
|
|
57
|
use Carp ( 'confess' ); |
|
7
|
|
|
|
|
20
|
|
|
7
|
|
|
|
|
693
|
|
7
|
7
|
|
|
7
|
|
59
|
use List::Util ( 'any' ); |
|
7
|
|
|
|
|
21
|
|
|
7
|
|
|
|
|
1008
|
|
8
|
7
|
|
|
7
|
|
57
|
use Params::Callbacks ( 'callbacks' ); |
|
7
|
|
|
|
|
22
|
|
|
7
|
|
|
|
|
485
|
|
9
|
7
|
|
|
7
|
|
8880
|
use Time::HiRes ( 'gettimeofday', 'tv_interval' ); |
|
7
|
|
|
|
|
14239
|
|
|
7
|
|
|
|
|
45
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
{ |
12
|
|
|
|
|
|
|
my $value = 60; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub timeout |
15
|
|
|
|
|
|
|
{ |
16
|
0
|
|
|
0
|
0
|
|
my ( $invocant, $new_value ) = @_; |
17
|
0
|
0
|
|
|
|
|
return $value unless @_ > 1; |
18
|
0
|
|
|
|
|
|
$value = $new_value; |
19
|
0
|
|
|
|
|
|
return $invocant; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub timeout_exceeded |
23
|
|
|
|
|
|
|
{ |
24
|
0
|
|
|
0
|
0
|
|
my ( $invocant, $tv_start ) = @_; |
25
|
0
|
|
|
|
|
|
return tv_interval( $tv_start ) > $value; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub wait_while_status_in |
30
|
|
|
|
|
|
|
{ |
31
|
0
|
|
|
0
|
0
|
|
my ( $callbacks, $invocant, @states ) = &callbacks; |
32
|
0
|
|
|
|
|
|
my $start_time = [ gettimeofday() ]; |
33
|
0
|
|
|
|
|
|
my $delay = 0.5; |
34
|
0
|
|
|
|
|
|
my $backoff = 0.25; |
35
|
0
|
|
|
|
|
|
while ( !$invocant->timeout_exceeded( $start_time ) ) { |
36
|
|
|
|
|
|
|
return $invocant |
37
|
0
|
0
|
|
0
|
|
|
unless any { /^$invocant->{object_status}$/ } @states; |
|
0
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
sleep( $delay ); |
39
|
0
|
|
|
|
|
|
$delay += $backoff; |
40
|
0
|
0
|
|
|
|
|
last unless $callbacks->transform( $invocant->refresh ); |
41
|
|
|
|
|
|
|
} |
42
|
0
|
0
|
|
|
|
|
confess 'Asynchronus operation timed-out' |
43
|
|
|
|
|
|
|
if $invocant->timeout_exceeded( $start_time ); |
44
|
0
|
|
|
|
|
|
return; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
BEGIN { |
48
|
7
|
|
|
7
|
|
3897
|
no warnings 'once'; |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
447
|
|
49
|
7
|
|
|
7
|
|
20
|
*Shippo::Async:: = *WebService::Shippo::Async::; |
50
|
7
|
|
|
|
|
190
|
*wait_if_status_in = *wait_while_status_in; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |