File Coverage

blib/lib/Redis/Fast/Sentinel.pm
Criterion Covered Total %
statement 12 24 50.0
branch 0 6 0.0
condition n/a
subroutine 4 7 57.1
pod 3 3 100.0
total 19 40 47.5


line stmt bran cond sub pod time code
1             package Redis::Fast::Sentinel;
2              
3             # ABSTRACT: Redis::Fast Sentinel interface
4              
5 38     38   305 use warnings;
  38         103  
  38         5032  
6 38     38   260 use strict;
  38         79  
  38         1400  
7              
8 38     38   247 use Carp;
  38         69  
  38         3754  
9              
10 38     38   277 use base qw(Redis::Fast);
  38         87  
  38         15656  
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             # Do not support SSL for sentinels
17 0           $args{ssl} = 0;
18              
19 0           $class->SUPER::new(%args);
20             }
21              
22             sub get_service_address {
23 0     0 1   my ($self, $service) = @_;
24 0           my ($ip, $port) = $self->sentinel('get-master-addr-by-name', $service);
25 0 0         defined $ip
26             or return;
27 0 0         $ip eq 'IDONTKNOW'
28             and return $ip;
29 0           return "$ip:$port";
30             }
31              
32             sub get_masters {
33 0 0   0 1   map { +{ @$_ }; } @{ shift->sentinel('masters') || [] };
  0            
  0            
34             }
35              
36             1;
37              
38             __END__