line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
6
|
|
|
6
|
|
76456
|
use utf8; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
30
|
|
2
|
6
|
|
|
6
|
|
191
|
use strict; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
167
|
|
3
|
6
|
|
|
6
|
|
30
|
use warnings; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
238
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package DR::TarantoolQueue::PackUnpack; |
6
|
6
|
|
|
6
|
|
361
|
use Mouse; |
|
6
|
|
|
|
|
20417
|
|
|
6
|
|
|
|
|
34
|
|
7
|
6
|
|
|
6
|
|
4655
|
use Compress::Zlib; |
|
6
|
|
|
|
|
323384
|
|
|
6
|
|
|
|
|
1224
|
|
8
|
6
|
|
|
6
|
|
1939
|
use MIME::Base64; |
|
6
|
|
|
|
|
3273
|
|
|
6
|
|
|
|
|
345
|
|
9
|
|
|
|
|
|
|
|
10
|
6
|
|
|
6
|
|
663
|
use JSON::XS; |
|
6
|
|
|
|
|
7417
|
|
|
6
|
|
|
|
|
1961
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has jsp => |
13
|
|
|
|
|
|
|
is => 'ro', |
14
|
|
|
|
|
|
|
isa => 'Object', |
15
|
|
|
|
|
|
|
lazy => 1, |
16
|
|
|
|
|
|
|
builder => sub { |
17
|
|
|
|
|
|
|
return JSON::XS |
18
|
|
|
|
|
|
|
-> new |
19
|
|
|
|
|
|
|
-> allow_nonref |
20
|
|
|
|
|
|
|
-> allow_blessed |
21
|
|
|
|
|
|
|
-> convert_blessed |
22
|
|
|
|
|
|
|
-> utf8; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has gzip_size_limit => is => 'ro', isa => 'Int', default => 1024 * 1024; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub encode { |
29
|
13
|
|
|
13
|
0
|
16451
|
my ($self, $data) = @_; |
30
|
13
|
|
|
|
|
92
|
my $pkt = $self->jsp->encode($data); |
31
|
|
|
|
|
|
|
|
32
|
13
|
100
|
|
|
|
77
|
return $pkt unless length $pkt >= $self->gzip_size_limit; |
33
|
|
|
|
|
|
|
|
34
|
6
|
|
|
|
|
16
|
$pkt = Compress::Zlib::memGzip($pkt); |
35
|
6
|
50
|
|
|
|
1166
|
die "Can't compress data: " . $gzerrno unless defined $pkt; |
36
|
6
|
|
|
|
|
60
|
return join ':', 'base64', encode_base64 $pkt, ''; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub decode { |
40
|
6
|
|
|
6
|
0
|
11
|
my ($self, $data) = @_; |
41
|
|
|
|
|
|
|
|
42
|
6
|
50
|
|
|
|
13
|
return undef unless defined $data; |
43
|
|
|
|
|
|
|
|
44
|
6
|
100
|
|
|
|
42
|
return $self->jsp->decode($data) unless $data =~ /^base64:/; |
45
|
3
|
|
|
|
|
17
|
my $raw = decode_base64 substr $data, 7; |
46
|
|
|
|
|
|
|
|
47
|
3
|
|
|
|
|
10
|
$raw = Compress::Zlib::memGunzip($raw); |
48
|
3
|
|
|
|
|
297
|
return $self->jsp->decode($raw); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |