RegMgr/Service.pm

filter: Statementstmt 52.0% 25 / 48 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 53.3% 8 / 15 Podpod 40.0% 2 / 5 totaltotal 47.3% 35 / 74 CC 4 SCAR 12.8
CC
4
Cov
46%
update
12.0
STOP
6.0
new
2.0
CRAP 3.6
« RegMgr/Monitor.pm ↑ Summary RegMgr/Lookup.pm »
1 package Inferno::RegMgr::Service;
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  
13  
14 1 ▶use constant RETRY => 1; # sec, delay between re-connections
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16  
17 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
18 0 my ($class, $opt) = @_;
19 my $self = {
20 name => $opt->{name},
21 attr => $opt->{attr},
22 0 manager => undef,
23 io => undef,
24 t => undef,
25 };
26 0 return bless $self, $class;
27 }
28  
29 0 ▶sub START {
Subroutine START: not called CC=1 SCAR=6.9
Pod undocumented
30 0 my ($self) = @_;
31 $self->{io} = $self->{manager}{registry}->open_new({
32 name => $self->{name},
33 attr => $self->{attr},
34 0 cb => $self,
35 method => '_cb_new',
36 });
37 0 weaken( $self->{io} );
38 0 return;
39 }
40  
41 0 ▶sub _cb_new { ## no critic(ProhibitUnusedPrivateSubroutines)
Subroutine _cb_new: not called CC=1 SCAR=6.9
42 0 my ($self, $err) = @_;
43 0 ▶ $self->{t} = EV::timer RETRY, 0, sub { $self->START() };
Subroutine __ANON__: not called CC=1 SCAR=6.9
44 0 return;
45 }
46  
47 0 ▶sub STOP {
Subroutine STOP: not called CC=2 SCAR=17.9
Pod undocumented
48 0 my ($self) = @_;
49 0 ▶ if (defined $self->{io}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"io"}) 0 0 0
50 0 $self->{io}->close();
51 }
52 0 $self->{t} = undef;
53 0 return;
54 }
55  
56 0 ▶sub update {
Subroutine update: not called CC=3 SCAR=24.8
Pod documented
57 0 my ($self, $attrs) = @_;
58 0 ▶ while (my ($attr, $val) = each %{ $attrs }) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$attrs;}) 0 0 0
59 0 $self->{attr}{ $attr } = $val;
60 }
61 0 ▶ if (defined $self->{io}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"io"}) 0 0 0
62 0 $self->{manager}{registry}->update($self->{io}, $attrs);
63 }
64 0 return;
65 }
66  
67 0 ▶sub REFRESH {}
Subroutine REFRESH: not called CC=1 SCAR=0.0
Pod undocumented
68  
69  
70 1 1; # Magic true value required at end of module
71 __END__
« RegMgr/Monitor.pm ↑ Summary RegMgr/Lookup.pm »