blib/lib/Catalyst/Model/Tarantool.pm

filter: Statementstmt 61.7% 29 / 47 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 15 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 81.8% 9 / 11 Podpod 50.0% 1 / 2 totaltotal 43.8% 39 / 89 CC 8 SCAR 28.0
CC
8
Cov
44%
new
42.0
handler
12.0
BEGIN
1.0
CRAP 16.5
↑ Summary
1 package Catalyst::Model::Tarantool;
2  
3 1 ▶use 5.014002;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use base 'Catalyst::Model';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use MRO::Compat;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use mro 'c3';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use DR::Tarantool::SyncClient;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Catalyst::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 our $VERSION = '0.02';
16  
17 1 __PACKAGE__->mk_accessors( qw/_handler app/ );
18  
19 0 ▶sub new {
Subroutine new: not called CC=6 SCAR=37.4
Pod documented
20 0 my ( $class, $c, $config ) = @_;
21 0 my $self = shift->next::method( @_ );
22 0 ▶ $self->{host} ||= $config->{host};
Condition0%0/3
$self->{"host"} ||= $config->{"host"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"host"} ||= $config->{"host"}
$self->{"host"} $config->{"host"}
Truth table0%0/3
A ||= B
A= $self->{"host"}B= $config->{"host"}
ABresult
1X1
011
000
23 0 ▶ $self->{port} ||= $config->{port};
Condition0%0/3
$self->{"port"} ||= $config->{"port"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"port"} ||= $config->{"port"}
$self->{"port"} $config->{"port"}
Truth table0%0/3
A ||= B
A= $self->{"port"}B= $config->{"port"}
ABresult
1X1
011
000
24 0 ▶ $self->{spaces} ||= $config->{spaces};
Condition0%0/3
$self->{"spaces"} ||= $config->{"spaces"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"spaces"} ||= $config->{"spaces"}
$self->{"spaces"} $config->{"spaces"}
Truth table0%0/3
A ||= B
A= $self->{"spaces"}B= $config->{"spaces"}
ABresult
1X1
011
000
25 0 ▶ $self->{reconnect_period} ||= $config->{reconnect_period};
Condition0%0/3
$self->{"reconnect_period"} ||= $config->{"reconnect_period"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"reconnect_period"} ||= $config->{"reconnect_period"}
$self->{"reconnect_period"} $config->{"reconnect_period"}
Truth table0%0/3
A ||= B
A= $self->{"reconnect_period"}B= $config->{"reconnect_period"}
ABresult
1X1
011
000
26 0 ▶ $self->{reconnect_always} ||= $config->{reconnect_always};
Condition0%0/3
$self->{"reconnect_always"} ||= $config->{"reconnect_always"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"reconnect_always"} ||= $config->{"reconnect_always"}
$self->{"reconnect_always"} $config->{"reconnect_always"}
Truth table0%0/3
A ||= B
A= $self->{"reconnect_always"}B= $config->{"reconnect_always"}
ABresult
1X1
011
000
27 0 $self->app($c);
28 0 return $self;
29 }
30  
31 0 ▶sub handler{
Subroutine handler: not called CC=3 SCAR=24.8
Pod undocumented
32 0 my ($self) = @_;
33 0 my $connection = $self->_handler;
34 0 ▶ unless ( $connection ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($connection) 0 0 0
35 0 eval {
36 my $connection = DR::Tarantool::SyncClient->connect(
37 host => $self->{host},
38 port => $self->{port},
39 spaces => $self->{spaces},
40 0 reconnect_period => 0.5,
41 reconnect_always => 1
42 );
43
44 0 $self->_handler( $connection );
45 };
46 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
47 0 Catalyst::Exception->throw( qq/Couldn't connect to the Tarantool via DR::Tarantool - "$@"/ );
48 }
49 }
50 0 return $self->_handler;
51 }
52  
53 # Preloaded methods go here.
54  
55 1 1;
56 __END__
↑ Summary