Redis/Sentinel.pm

filter: Statementstmt 56.0% 14 / 25 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 57.1% 4 / 7 Podpod 100% 3 / 3 totaltotal 50.0% 21 / 42 CC 4 SCAR 16.9
CC
4
Cov
45%
get_service_address
12.0
get_masters
6.0
new
2.0
CRAP 5.4
« Redis.pm ↑ Summary Redis/Hash.pm »
1 #
2 # This file is part of Redis
3 #
4 # This software is Copyright (c) 2015 by Pedro Melo, Damien Krotkine.
5 #
6 # This is free software, licensed under:
7 #
8 # The Artistic License 2.0 (GPL Compatible)
9 #
10 package Redis::Sentinel;
11 19 $Redis::Sentinel::VERSION = '2.000';
12 # ABSTRACT: Redis Sentinel interface
13  
14 19 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 19 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 19 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 19 ▶use base qw(Redis);
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
22 0 my ($class, %args) = @_;
23 # these args are not allowed when contacting a sentinel
24 0 delete @args{qw(sentinels service)};
25  
26 0 $class->SUPER::new(%args);
27 }
28  
29 0 ▶sub get_service_address {
Subroutine get_service_address: not called CC=3 SCAR=24.8
Pod documented
30 0 my ($self, $service) = @_;
31 0 my ($ip, $port) = $self->sentinel('get-master-addr-by-name', $service);
32 0 ▶ defined $ip
Branch: 1 branch
BranchTrueFalseTotal
defined $ip or return 0 0 0
33 or return;
34 0 ▶ $ip eq 'IDONTKNOW'
Branch: 1 branch
BranchTrueFalseTotal
$ip eq "IDONTKNOW" and return $ip 0 0 0
35 and return $ip;
36 0 return "$ip:$port";
37 }
38  
39 0 ▶sub get_masters {
Subroutine get_masters: not called CC=2 SCAR=17.9
Pod documented
40 0 ▶ map { +{ @$_ }; } @{ shift->sentinel('masters') || [] };
Condition0%0/2
(shift())->sentinel('masters') || []
l!l
00
MC/DC0%0/1
(shift())->sentinel('masters') || []
(shift())->sentinel('masters')
Truth table0%0/2
A
A= (shift())->sentinel('masters')
Aresult
11
00
41 }
42  
43 19 1;
44  
45 __END__
« Redis.pm ↑ Summary Redis/Hash.pm »