Supervisor/Supervised/Proc.pm

filter: Statementstmt 100% 16 / 16 Branchbran n/a Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 92.3% 24 / 26 SCAR 6.9
CC
2
Cov
95%
is_abnormal_exit
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« Supervisor/Handle.pm ↑ Summary Supervisor/Handle/Interface.pm »
1 #!/usr/bin/perl
2  
3 package POE::Component::Supervisor::Supervised::Proc;
4 22 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 22 ▶use POE::Component::Supervisor::Handle::Proc;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 22 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 22 with qw(POE::Component::Supervisor::Supervised);
11  
12 22 has '+handle_class' => ( default => "POE::Component::Supervisor::Handle::Proc" );
13  
14 22 __PACKAGE__->_inherit_attributes_from_handle_class;
15  
16 sub is_abnormal_exit {
17 75 ▶ my ( $self, %args ) = @_;
Subroutine is_abnormal_exit: called CC=2 SCAR=7.0
Pod documented
18  
19 75 my $exit_code = $args{exit_code};
20  
21 75 ▶ return ( defined($exit_code) and $exit_code != 0 );
Condition66%2/3
defined $exit_code && $exit_code != 0
!ll&&!rl&&r
01362
MC/DC50%1/2
defined $exit_code && $exit_code != 0
defined $exit_code $exit_code != 0
Truth table66%2/3
A && B
A= defined $exit_codeB= $exit_code != 0
ABresult
0X0
100
111
22 }
23  
24 22 __PACKAGE__
25  
26 __END__
27  
28 =pod
29  
30 =head1 NAME
31  
32 POE::Component::Supervisor::Supervised::Proc - A supervision descriptor for UNIX processes.
33  
34 =head1 SYNOPSIS
35  
36 use POE;
37  
38 use POE::Component::Supervisor;
39 use POE::Component::Supervisor::Supervised::Proc;
40  
41 POE::Component::Supervisor->new(
42 children => [
43 POE::Component::Supervisor::Supervised::Proc->new(
44 program => [qw(memcached -m 64)],
45 restart_policy => "permanent",
46 ),
47 ],
48 );
49  
50 $poe_kernel->run;
51  
52 =head1 DESCRIPTION
53  
54 This is a factory object that creates L<POE::Component::Supervisor::Handle::Proc> objects.
55  
56 =head1 ATTRIBUTES
57  
58 See also L<POE::Component::Supervisor::Handle::Proc/ATTRIBUTES>, all of the
59 documented attributes that apply to handle creation are borrowed by this class.
60  
61 =over 4
62  
63 =item handle_class
64  
65 The class to instantiate.
66  
67 Defaults to L<POE::Component::Supervisor::Handle::Proc>.
68  
69 Note that attributes are inherited only from
70 L<POE::Component::Supervisor::Handle::Proc>. If your handle class requires
71 additional attributes, you must subclass your own C<Supervised> variant.
72  
73 The C<_inherit_attributes_from_handle_class> method can then be invoked on your
74 subclass to reinherit all the attributes. Read the source of
75 L<POE::Component::Supervisor::Supervised> for more details.
76  
77 =back
78  
79 =head1 METHODS
80  
81 See also L<POE::Component::Supervisor::Supervised/METHODS>.
82  
83 =over 4
84  
85 =item spawn
86  
87 Called by L<POE::Component::Supervisor> when a new instance of the child
88 process should be spawned.
89  
90 =item is_abnormal_exit
91  
92 Used by C<should_restart>. See L<POE::Component::Supervisor::Supervised> for
93 details.
94  
95 Returns true if the C<exit_code> argument is not equal to 0.
96  
97 =back
98  
99 =cut
100  
101  
« Supervisor/Handle.pm ↑ Summary Supervisor/Handle/Interface.pm »