| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
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
|
|
|
|
|
|
|
$Redis::Sentinel::VERSION = '1.998'; # TRIAL |
|
12
|
|
|
|
|
|
|
# ABSTRACT: Redis Sentinel interface |
|
13
|
|
|
|
|
|
|
|
|
14
|
15
|
|
|
15
|
|
107
|
use warnings; |
|
|
15
|
|
|
|
|
32
|
|
|
|
15
|
|
|
|
|
544
|
|
|
15
|
15
|
|
|
15
|
|
80
|
use strict; |
|
|
15
|
|
|
|
|
34
|
|
|
|
15
|
|
|
|
|
288
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
15
|
|
|
15
|
|
73
|
use Carp; |
|
|
15
|
|
|
|
|
31
|
|
|
|
15
|
|
|
|
|
865
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
15
|
|
|
15
|
|
93
|
use base qw(Redis); |
|
|
15
|
|
|
|
|
27
|
|
|
|
15
|
|
|
|
|
4284
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new { |
|
22
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub get_service_address { |
|
30
|
0
|
|
|
0
|
1
|
|
my ($self, $service) = @_; |
|
31
|
0
|
|
|
|
|
|
my ($ip, $port) = $self->sentinel('get-master-addr-by-name', $service); |
|
32
|
0
|
0
|
|
|
|
|
defined $ip |
|
33
|
|
|
|
|
|
|
or return; |
|
34
|
0
|
0
|
|
|
|
|
$ip eq 'IDONTKNOW' |
|
35
|
|
|
|
|
|
|
and return $ip; |
|
36
|
0
|
|
|
|
|
|
return "$ip:$port"; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub get_masters { |
|
40
|
0
|
0
|
|
0
|
1
|
|
map { +{ @$_ }; } @{ shift->sentinel('masters') || [] }; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |