blib/lib/Redis/Jet.pm

filter: Statementstmt 96.3% 52 / 54 Branchbran 41.6% 5 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 15 / 15 Podpod 33.3% 1 / 3 totaltotal 86.9% 73 / 84 CC 7 SCAR 11.1
CC
7
Cov
86%
connect
7.8
new
2.1
BEGIN
1.0
CRAP 3.0
« builder/MyBuilder.pm ↑ Summary lib/Redis/Jet.xs »
1 package Redis::Jet;
2  
3 14 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 14 ▶use POSIX qw(EINTR EAGAIN EWOULDBLOCK :sys_wait_h);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 14 ▶use IO::Socket qw(:crlf IPPROTO_TCP TCP_NODELAY);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 14 ▶use IO::Socket::INET;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 14 ▶use IO::Socket::UNIX;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 14 ▶use IO::Select;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 14 ▶use Time::HiRes qw/time/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 14 ▶use base qw/Exporter/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 14 our @EXPORT_OK = qw/
15 parse_message parse_message_utf8
16 /;
17  
18 14 our $VERSION = "0.09";
19  
20 14 ▶use XSLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 14 XSLoader::load(__PACKAGE__, $VERSION);
22  
23 8 ▶sub new {
Subroutine new: called CC=2 SCAR=7.4
Pod documented
24 8 my $class = shift;
25 0 ▶ my %args = ref $_[0] ? %{$_[0]} : @_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 8 8
26 8 %args = (
27 server => '127.0.0.1:6379',
28 connect_timeout => 5,
29 io_timeout => 1,
30 utf8 => 0,
31 noreply => 0,
32 reconnect_attempts => 0,
33 reconnect_delay => 0.1,
34 %args,
35 );
36 8 $class->_new(\%args);
37 }
38  
39 2 ▶sub set_socket {
Subroutine set_socket: called CC=1 SCAR=0.0
Pod undocumented
40 2 my ($self,$socket) = @_;
41 2 $self->get_bucket->{socket} = $socket;
42 2 $self->set_fileno(fileno($socket));
43 }
44  
45 2 ▶sub connect {
Subroutine connect: called CC=6 SCAR=20.5
Pod undocumented
46 2 my $self = shift;
47 2 my $socket;
48 2 ▶ if ($self->get_server =~ m!/!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_server =~ m[/]) { } 0 2 2
49 0 ▶ $socket = IO::Socket::UNIX->new(
Branch: 1 branch
BranchTrueFalseTotal
$socket = "IO::Socket::UNIX"->new("Peer", $self->get_server, "Timeout", $self->get_connect_timeout) or return 0 0 0
50 Peer => $self->get_server,
51 Timeout => $self->get_connect_timeout,
52 ) or return;
53 } else {
54 2 ▶ $socket = IO::Socket::INET->new(
Branch: 1 branch
BranchTrueFalseTotal
$socket = "IO::Socket::INET"->new("PeerAddr", $self->get_server, "Timeout", $self->get_connect_timeout) or return 2 0 2
55 PeerAddr => $self->get_server,
56 Timeout => $self->get_connect_timeout,
57 ) or return;
58 2 ▶ $socket->setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
Branch: 1 branch
BranchTrueFalseTotal
$socket->setsockopt(6, 1, 1) or die "setsockopt(TCP_NODELAY) failed:$!" 2 0 2
59 or die "setsockopt(TCP_NODELAY) failed:$!";
60 }
61 2 ▶ $socket->blocking(0) or die $!;
Branch: 1 branch
BranchTrueFalseTotal
$socket->blocking(0) or die $! 2 0 2
62 2 $self->set_socket($socket);
63 2 $socket;
64 }
65  
66 2 ▶sub DESTROY {
Subroutine DESTROY: called CC=1 SCAR=0.0
67 2 $_[0]->_destroy();
68 }
69  
70  
71 14 1;
72 __END__
« builder/MyBuilder.pm ↑ Summary lib/Redis/Jet.xs »