| 1 | package Inferno::RegMgr::Service; | ||||||||||
| 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 | |||||||||||
| 14 | |||||||||||
| 15 | 2 | ▶ | use constant RETRY => 1; # sec, delay between re-connections | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | |||||||||||
| 18 | sub new { | ||||||||||
| 19 | 0 | ▶ | my ($class, $opt) = @_; | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 20 | my $self = { | ||||||||||
| 21 | name => $opt->{name}, | ||||||||||
| 22 | attr => $opt->{attr}, | ||||||||||
| 23 | 0 | manager => undef, | |||||||||
| 24 | io => undef, | ||||||||||
| 25 | t => undef, | ||||||||||
| 26 | }; | ||||||||||
| 27 | 0 | return bless $self, $class; | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | sub START { | ||||||||||
| 31 | 0 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
START: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 32 | $self->{io} = $self->{manager}{registry}->open_new({ | ||||||||||
| 33 | name => $self->{name}, | ||||||||||
| 34 | attr => $self->{attr}, | ||||||||||
| 35 | 0 | cb => $self, | |||||||||
| 36 | method => '_cb_new', | ||||||||||
| 37 | }); | ||||||||||
| 38 | 0 | weaken( $self->{io} ); | |||||||||
| 39 | 0 | return; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | sub _cb_new { ## no critic(ProhibitUnusedPrivateSubroutines) | ||||||||||
| 43 | 0 | ▶ | my ($self, $err) = @_; | ||||||||
|
Subroutine
_cb_new: not called CC=1 SCAR=6.9
| |||||||||||
| 44 | 0 | ▶ | $self->{t} = EV::timer RETRY, 0, sub { $self->START() }; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 45 | 0 | return; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | sub STOP { | ||||||||||
| 49 | 0 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
STOP: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 50 | 0 | ▶ | if (defined $self->{io}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | 0 | $self->{io}->close(); | |||||||||
| 52 | } | ||||||||||
| 53 | 0 | $self->{t} = undef; | |||||||||
| 54 | 0 | return; | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | sub update { | ||||||||||
| 58 | 0 | ▶ | my ($self, $attrs) = @_; | ||||||||
|
Subroutine
update: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 59 | 0 | ▶ | while (my ($attr, $val) = each %{ $attrs }) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | 0 | $self->{attr}{ $attr } = $val; | |||||||||
| 61 | } | ||||||||||
| 62 | 0 | ▶ | if (defined $self->{io}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | 0 | $self->{manager}{registry}->update($self->{io}, $attrs); | |||||||||
| 64 | } | ||||||||||
| 65 | 0 | return; | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | ▶ | sub REFRESH {} | |||||||||
|
Subroutine
REFRESH: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 69 | |||||||||||
| 70 | |||||||||||
| 71 | 2 | 1; # Magic true value required at end of module | |||||||||
| 72 | __END__ | ||||||||||