Redis/Cluster/Node.pm

filter: Statementstmt 40.0% 18 / 45 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 27.7% 5 / 18 Podpod 9.0% 1 / 11 totaltotal 23.7% 24 / 101 CC 10 SCAR 25.2
CC
10
Cov
28%
from_arrayref
42.0
configure
12.0
id
6.0
CRAP 12.4
« Redis/Protocol.pm ↑ Summary Redis/Server/Connection.pm »
1 package Net::Async::Redis::Cluster::Node;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 our $VERSION = '2.004_001'; # TRIAL VERSION
7  
8 4 ▶use parent qw(IO::Async::Notifier);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 ▶use Future::AsyncAwait;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 use overload
13 0 ▶ '""' => sub { 'NaRedis::Cluster::Node[id=' . shift->id . ']' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
14 0 ▶ bool => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
15 4 ▶ fallback => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 sub configure {
18 0 ▶ my ($self, %args) = @_;
Subroutine configure: not called CC=3 SCAR=24.8
Pod documented
19 0 for my $k (qw(start end primary replicas)) {
20 0 ▶ $self->{$k} = delete $args{$k} if exists $args{$k};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{$k} 0 0 0
21 }
22 0 return $self->next::method(%args);
23 }
24  
25 sub from_arrayref {
26 0 ▶ my ($class, $arrayref) = @_;
Subroutine from_arrayref: not called CC=6 SCAR=37.4
Pod undocumented
27 0 my ($start, $end, $primary, @replicas) = $arrayref->@*;
28 0 ▶ die 'invalid start' if $start > $end or $start < 0 or $start >= 16384;
Branch: 1 branch
BranchTrueFalseTotal
if $start > $end or $start < 0 or $start >= 16384 0 0 0
Condition0%0/6
$start > $end or $start < 0 or $start >= 16384
l!l&&r!l&&!r
000
$start > $end or $start < 0
l!l&&r!l&&!r
000
MC/DC0%0/3
$start > $end or $start < 0 or $start >= 16384
$start > $end $start < 0 $start >= 16384
Truth table0%0/4
A or B or C
A= $start > $endB= $start < 0C= $start >= 16384
ABCresult
1XX1
01X1
0011
0000
29 0 ▶ die 'invalid end' if $end >= 16384;
Branch: 1 branch
BranchTrueFalseTotal
if $end >= 16384 0 0 0
30 0 ▶ die 'no primary found' unless $primary;
Branch: 1 branch
BranchTrueFalseTotal
unless $primary 0 0 0
31 0 return $class->new(
32 start => $start,
33 end => $end,
34 primary => $primary,
35 replicas => \@replicas,
36 )
37 }
38 0 ▶sub start { shift->{start} }
Subroutine start: not called CC=1 SCAR=6.9
Pod undocumented
39 0 ▶sub end { shift->{end} }
Subroutine end: not called CC=1 SCAR=6.9
Pod undocumented
40 0 ▶sub primary { shift->{primary} }
Subroutine primary: not called CC=1 SCAR=6.9
Pod undocumented
41 0 ▶sub replicas { shift->{replicas} }
Subroutine replicas: not called CC=1 SCAR=6.9
Pod undocumented
42 0 ▶sub replica_list { shift->{replicas}->@* }
Subroutine replica_list: not called CC=1 SCAR=6.9
Pod undocumented
43 0 ▶sub replica_count { 0 + shift->{replicas}->@* }
Subroutine replica_count: not called CC=1 SCAR=6.9
Pod undocumented
44 0 ▶sub id { $_[0]->{primary}[2] // $_[0]->host_port }
Subroutine id: not called CC=2 SCAR=17.9
Pod undocumented
Condition0%0/3
$_[0]{"primary"}[2] // $_[0]->host_port
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[0]{"primary"}[2] // $_[0]->host_port
$_[0]{"primary"}[2] $_[0]->host_port
Truth table0%0/3
A // B
A= $_[0]{"primary"}[2]B= $_[0]->host_port
ABresult
1X1
011
000
45 0 ▶sub host_port { join ':', @{$_[0]->{primary}}[0, 1] }
Subroutine host_port: not called CC=1 SCAR=6.9
Pod undocumented
46  
47 0 ▶async sub primary_connection {
Subroutine primary_connection: not called CC=2 SCAR=17.9
Pod undocumented
48 0 my ($self) = @_;
49 0 ▶ return $self->{primary_connection} //= do {
Condition0%0/3
$self->{"primary_connection"} //= do { $self->add_child(my $redis = "Net::Async::Redis"->new("host", $self->primary->[0], "port", $self->primary->[1])); XXX; $redis }
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"primary_connection"} //= do { $self->add_child(my $redis = "Net::Async::Redis"->new("host", $self->primary->[0], "port", $self->primary->[1])); XXX; $redis }
$self->{"primary_connection"} do { $self->add_child(my $redis = "Net::Async::Redis"->new("host", $self->primary->[0], "port", $self->primary->[1])); XXX; $redis }
Truth table0%0/3
A //= B
A= $self->{"primary_connection"}B= do { $self->add_child(my $redis = "Net::Async::Redis"->new("host", $self->primary->[0], "port", $self->primary->[1])); XXX; $redis }
ABresult
1X1
011
000
50 0 $self->add_child(
51 my $redis = Net::Async::Redis->new(
52 host => $self->primary->[0],
53 port => $self->primary->[1],
54 )
55 );
56 0 await $redis->connected;
57 0 $redis
58 };
59 4 }
60  
61 4 1;
62  
63 =head1 AUTHOR
64  
65 Tom Molesworth C<< <TEAM@cpan.org> >> plus contributors as mentioned in
66 L<Net::Async::Redis/CONTRIBUTORS>.
67  
68 =head1 LICENSE
69  
70 Copyright Tom Molesworth 2015-2020. Licensed under the same terms as Perl itself.
71  
« Redis/Protocol.pm ↑ Summary Redis/Server/Connection.pm »