| 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"}
MC/DC0%0/2
$self->{"host"} ||= $config->{"host"}
$self->{"host"}
$config->{"host"}
Truth table0%0/3
A ||= B
A= $self->{"host"}B= $config->{"host"}
| |||||||||||||||||||||
| 23 | 0 | ▶ | $self->{port} ||= $config->{port}; | ||||||||||||||||||
|
Condition0%0/3
$self->{"port"} ||= $config->{"port"}
MC/DC0%0/2
$self->{"port"} ||= $config->{"port"}
$self->{"port"}
$config->{"port"}
Truth table0%0/3
A ||= B
A= $self->{"port"}B= $config->{"port"}
| |||||||||||||||||||||
| 24 | 0 | ▶ | $self->{spaces} ||= $config->{spaces}; | ||||||||||||||||||
|
Condition0%0/3
$self->{"spaces"} ||= $config->{"spaces"}
MC/DC0%0/2
$self->{"spaces"} ||= $config->{"spaces"}
$self->{"spaces"}
$config->{"spaces"}
Truth table0%0/3
A ||= B
A= $self->{"spaces"}B= $config->{"spaces"}
| |||||||||||||||||||||
| 25 | 0 | ▶ | $self->{reconnect_period} ||= $config->{reconnect_period}; | ||||||||||||||||||
|
Condition0%0/3
$self->{"reconnect_period"} ||= $config->{"reconnect_period"}
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"}
| |||||||||||||||||||||
| 26 | 0 | ▶ | $self->{reconnect_always} ||= $config->{reconnect_always}; | ||||||||||||||||||
|
Condition0%0/3
$self->{"reconnect_always"} ||= $config->{"reconnect_always"}
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"}
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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__ | ||||||||||||||||||||