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.999'; |
12
|
|
|
|
|
|
|
# ABSTRACT: Redis Sentinel interface |
13
|
|
|
|
|
|
|
|
14
|
15
|
|
|
15
|
|
113
|
use warnings; |
|
15
|
|
|
|
|
32
|
|
|
15
|
|
|
|
|
593
|
|
15
|
15
|
|
|
15
|
|
81
|
use strict; |
|
15
|
|
|
|
|
30
|
|
|
15
|
|
|
|
|
293
|
|
16
|
|
|
|
|
|
|
|
17
|
15
|
|
|
15
|
|
67
|
use Carp; |
|
15
|
|
|
|
|
24
|
|
|
15
|
|
|
|
|
893
|
|
18
|
|
|
|
|
|
|
|
19
|
15
|
|
|
15
|
|
96
|
use base qw(Redis); |
|
15
|
|
|
|
|
25
|
|
|
15
|
|
|
|
|
4440
|
|
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__ |