File Coverage

blib/lib/Redis/Fast/Sentinel.pm
Criterion Covered Total %
statement 12 23 52.1
branch 0 6 0.0
condition n/a
subroutine 4 7 57.1
pod 3 3 100.0
total 19 39 48.7


line stmt bran cond sub pod time code
1             package Redis::Fast::Sentinel;
2              
3             # ABSTRACT: Redis::Fast Sentinel interface
4              
5 38     38   262 use warnings;
  38         115  
  38         1192  
6 38     38   214 use strict;
  38         84  
  38         669  
7              
8 38     38   163 use Carp;
  38         76  
  38         1884  
9              
10 38     38   217 use base qw(Redis::Fast);
  38         82  
  38         13723  
11              
12             sub new {
13 0     0 1   my ($class, %args) = @_;
14             # these args are not allowed when contacting a sentinel
15 0           delete @args{qw(sentinels service)};
16              
17 0           $class->SUPER::new(%args);
18             }
19              
20             sub get_service_address {
21 0     0 1   my ($self, $service) = @_;
22 0           my ($ip, $port) = $self->sentinel('get-master-addr-by-name', $service);
23 0 0         defined $ip
24             or return;
25 0 0         $ip eq 'IDONTKNOW'
26             and return $ip;
27 0           return "$ip:$port";
28             }
29              
30             sub get_masters {
31 0 0   0 1   map { +{ @$_ }; } @{ shift->sentinel('masters') || [] };
  0            
  0            
32             }
33              
34             1;
35              
36             __END__