| 1 | package Inferno::RegMgr::Lookup; | ||||||||||
| 2 | 1 | ▶ | use 5.010001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | our $VERSION = 'v1.0.0'; | |||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use Scalar::Util qw( weaken ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use EV; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use Inferno::RegMgr::Utils qw( run_callback ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | |||||||||||
| 15 | 1 | ▶ | use constant RETRY => 1; # sec, delay between re-connections | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | |||||||||||
| 18 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 19 | 0 | my ($class, $opt) = @_; | |||||||||
| 20 | my $self = { | ||||||||||
| 21 | attr => $opt->{attr}, | ||||||||||
| 22 | cb => $opt->{cb}, | ||||||||||
| 23 | method => $opt->{method}, | ||||||||||
| 24 | 0 | manager => undef, | |||||||||
| 25 | io => undef, | ||||||||||
| 26 | t => undef, | ||||||||||
| 27 | }; | ||||||||||
| 28 | 0 | return bless $self, $class; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 0 | ▶ | sub START { | ||||||||
|
Subroutine
START: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 32 | 0 | my ($self) = @_; | |||||||||
| 33 | $self->{io} = $self->{manager}{registry}->open_find({ | ||||||||||
| 34 | attr => $self->{attr}, | ||||||||||
| 35 | 0 | cb => $self, | |||||||||
| 36 | method => '_cb_find', | ||||||||||
| 37 | }); | ||||||||||
| 38 | 0 | weaken( $self->{io} ); | |||||||||
| 39 | 0 | return; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 0 | ▶ | sub _cb_find { ## no critic(ProhibitUnusedPrivateSubroutines) | ||||||||
|
Subroutine
_cb_find: not called CC=2 SCAR=17.9
| |||||||||||
| 43 | 0 | my ($self, $svc, $err) = @_; | |||||||||
| 44 | 0 | ▶ | if ($svc) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 0 | $self->{manager}->detach( $self ); | |||||||||
| 46 | 0 | run_callback( $self->{cb}, $self->{method}, $svc ); | |||||||||
| 47 | } | ||||||||||
| 48 | else { | ||||||||||
| 49 | 0 | ▶ | $self->{t} = EV::timer RETRY, 0, sub { $self->START() }; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 50 | } | ||||||||||
| 51 | 0 | return; | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 0 | ▶ | sub STOP { | ||||||||
|
Subroutine
STOP: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 55 | 0 | my ($self) = @_; | |||||||||
| 56 | 0 | ▶ | if (defined $self->{io}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | 0 | $self->{io}->close(); | |||||||||
| 58 | } | ||||||||||
| 59 | 0 | $self->{t} = undef; | |||||||||
| 60 | 0 | return; | |||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | 0 | ▶ | sub REFRESH {} | ||||||||
|
Subroutine
REFRESH: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 64 | |||||||||||
| 65 | |||||||||||
| 66 | 1 | 1; # Magic true value required at end of module | |||||||||
| 67 | __END__ | ||||||||||