line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Redis::Fast::Sentinel; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Redis::Fast Sentinel interface |
4
|
|
|
|
|
|
|
|
5
|
38
|
|
|
38
|
|
218
|
use warnings; |
|
38
|
|
|
|
|
72
|
|
|
38
|
|
|
|
|
1079
|
|
6
|
38
|
|
|
38
|
|
186
|
use strict; |
|
38
|
|
|
|
|
70
|
|
|
38
|
|
|
|
|
611
|
|
7
|
|
|
|
|
|
|
|
8
|
38
|
|
|
38
|
|
194
|
use Carp; |
|
38
|
|
|
|
|
69
|
|
|
38
|
|
|
|
|
1691
|
|
9
|
|
|
|
|
|
|
|
10
|
38
|
|
|
38
|
|
200
|
use base qw(Redis::Fast); |
|
38
|
|
|
|
|
55
|
|
|
38
|
|
|
|
|
11509
|
|
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__ |