| 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 | 19 | $Redis::Sentinel::VERSION = '2.000'; | |||||||||||
| 12 | # ABSTRACT: Redis Sentinel interface | ||||||||||||
| 13 | |||||||||||||
| 14 | 19 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 15 | 19 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 16 | |||||||||||||
| 17 | 19 | ▶ | use Carp; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 18 | |||||||||||||
| 19 | 19 | ▶ | use base qw(Redis); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 20 | |||||||||||||
| 21 | 0 | ▶ | sub new { | ||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 22 | 0 | 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 | 0 | ▶ | sub get_service_address { | ||||||||||
|
Subroutine
get_service_address: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||
| 30 | 0 | my ($self, $service) = @_; | |||||||||||
| 31 | 0 | my ($ip, $port) = $self->sentinel('get-master-addr-by-name', $service); | |||||||||||
| 32 | 0 | ▶ | defined $ip | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 33 | or return; | ||||||||||||
| 34 | 0 | ▶ | $ip eq 'IDONTKNOW' | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 35 | and return $ip; | ||||||||||||
| 36 | 0 | return "$ip:$port"; | |||||||||||
| 37 | } | ||||||||||||
| 38 | |||||||||||||
| 39 | 0 | ▶ | sub get_masters { | ||||||||||
|
Subroutine
get_masters: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 40 | 0 | ▶ | map { +{ @$_ }; } @{ shift->sentinel('masters') || [] }; | ||||||||||
|
Condition0%0/2
(shift())->sentinel('masters') || []
MC/DC0%0/1
(shift())->sentinel('masters') || []
(shift())->sentinel('masters')
Truth table0%0/2
A
A= (shift())->sentinel('masters')
| |||||||||||||
| 41 | } | ||||||||||||
| 42 | |||||||||||||
| 43 | 19 | 1; | |||||||||||
| 44 | |||||||||||||
| 45 | __END__ | ||||||||||||