RegMgr/Lookup.pm

filter: Statementstmt 57.7% 26 / 45 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 8 / 14 Podpod 25.0% 1 / 4 totaltotal 52.2% 35 / 67 SCAR 13.7
CC
3
Cov
53%
_cb_find
6.0
STOP
6.0
new
2.0
CRAP 3.9
« RegMgr/Service.pm ↑ Summary
1 package Inferno::RegMgr::Lookup;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # update POD & Changes & README
8 2 ▶use version; our $VERSION = qv('0.1.0');
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # update DEPENDENCIES in POD & Makefile.PL & README
11 2 ▶use Scalar::Util qw( weaken );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use EV;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Inferno::RegMgr::Utils qw( run_callback );
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15  
16 2 ▶use constant RETRY => 1; # sec, delay between re-connections
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18  
19 sub new {
20 0 ▶ my ($class, $opt) = @_;
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
21 my $self = {
22 attr => $opt->{attr},
23 cb => $opt->{cb},
24 method => $opt->{method},
25 0 manager => undef,
26 io => undef,
27 t => undef,
28 };
29 0 return bless $self, $class;
30 }
31  
32 sub START {
33 0 ▶ my ($self) = @_;
Subroutine START: not called CC=1 SCAR=6.9
Pod undocumented
34 $self->{io} = $self->{manager}{registry}->open_find({
35 attr => $self->{attr},
36 0 cb => $self,
37 method => '_cb_find',
38 });
39 0 weaken( $self->{io} );
40 0 return;
41 }
42  
43 sub _cb_find { ## no critic(ProhibitUnusedPrivateSubroutines)
44 0 ▶ my ($self, $svc, $err) = @_;
Subroutine _cb_find: not called CC=2 SCAR=17.9
45 0 ▶ if ($svc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($svc) { } 0 0 0
46 0 $self->{manager}->detach( $self );
47 0 run_callback( $self->{cb}, $self->{method}, $svc );
48 }
49 else {
50 0 ▶ $self->{t} = EV::timer RETRY, 0, sub { $self->START() };
Subroutine __ANON__: not called CC=1 SCAR=6.9
51 }
52 0 return;
53 }
54  
55 sub STOP {
56 0 ▶ my ($self) = @_;
Subroutine STOP: not called CC=2 SCAR=17.9
Pod undocumented
57 0 ▶ if (defined $self->{io}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"io"}) 0 0 0
58 0 $self->{io}->close();
59 }
60 0 $self->{t} = undef;
61 0 return;
62 }
63  
64 ▶sub REFRESH {}
Subroutine REFRESH: not called CC=1 SCAR=0.0
Pod undocumented
65  
66  
67 2 1; # Magic true value required at end of module
68 __END__
« RegMgr/Service.pm ↑ Summary