blib/lib/XAS/Lib/POE/Service.pm

filter: Statementstmt 15.6% 8 / 51 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 16.6% 2 / 12 Podpod 100% 5 / 5 totaltotal 21.4% 15 / 70 CC 2 SCAR 9.0
CC
2
Cov
15%
session_status
6.0
session_initialize
2.0
session_idle
2.0
CRAP 2.5
« blib/lib/XAS/Lib/App/Service/Unix.pm ↑ Summary blib/lib/XAS/Lib/App.pm »
1 package XAS::Lib::POE::Service;
2  
3 1 our $VERSION = '0.03';
4  
5 1 ▶use POE;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 use XAS::Class
8 1 debug => 0,
9 version => $VERSION,
10 base => 'XAS::Lib::POE::Session',
11 vars => {
12 PARAMS => {
13 -alias => { optional => 1, default => 'service' }
14 }
15 }
16 1 ▶;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 # ----------------------------------------------------------------------
19 # Public Events
20 # ----------------------------------------------------------------------
21  
22 # ----------------------------------------------------------------------
23 # Public Methods
24 # ----------------------------------------------------------------------
25  
26 sub session_initialize {
27 0 ▶ my $self = shift;
Subroutine session_initialize: not called CC=1 SCAR=6.9
Pod documented
28  
29 0 my $alias = $self->alias;
30  
31 0 $self->log->debug("$alias: session_initialize()");
32  
33 0 $poe_kernel->state('session_idle', $self, '_session_idle');
34 0 $poe_kernel->state('session_pause', $self, '_session_pause');
35 0 $poe_kernel->state('session_resume', $self, '_session_resume');
36 0 $poe_kernel->state('session_status', $self, '_session_status');
37  
38 0 $poe_kernel->sig('HUP', 'session_interrupt');
39  
40 }
41  
42 sub session_idle {
43 0 ▶ my $self = shift;
Subroutine session_idle: not called CC=1 SCAR=6.9
Pod documented
44  
45 0 my $alias = $self->alias;
46  
47 0 $self->log->debug("$alias: session_idle()");
48  
49 }
50  
51 sub session_pause {
52 0 ▶ my $self = shift;
Subroutine session_pause: not called CC=1 SCAR=6.9
Pod documented
53  
54 0 my $alias = $self->alias;
55  
56 0 $self->log->debug("$alias: session_pause()");
57  
58 }
59  
60 sub session_resume {
61 0 ▶ my $self = shift;
Subroutine session_resume: not called CC=1 SCAR=6.9
Pod documented
62  
63 0 my $alias = $self->alias;
64  
65 0 $self->log->debug("$alias: session_resume()");
66  
67 }
68  
69 sub session_status {
70 0 ▶ my $self = shift;
Subroutine session_status: not called CC=2 SCAR=17.9
Pod documented
71 0 my $status = shift;
72  
73 0 my $alias = $self->alias;
74  
75 0 $self->log->debug("$alias: session_status()");
76  
77 0 ▶ $self->{'__status'} = $status if (defined($status));
Branch: 1 branch
BranchTrueFalseTotal
if defined $status 0 0 0
78  
79 0 return $self->{'__status'};
80  
81 }
82  
83 # ----------------------------------------------------------------------
84 # Public Accessors
85 # ----------------------------------------------------------------------
86  
87 # ----------------------------------------------------------------------
88 # Private Methods
89 # ----------------------------------------------------------------------
90  
91 # ----------------------------------------------------------------------
92 # Private Events
93 # ----------------------------------------------------------------------
94  
95 sub _session_init {
96 0 ▶ my ($self) = $_[OBJECT];
Subroutine _session_init: not called CC=1 SCAR=6.9
97  
98 0 my $alias = $self->alias;
99  
100 0 $self->log->debug("$alias: _session_init()");
101  
102 0 $self->session_initialize();
103  
104 }
105  
106 sub _session_idle {
107 0 ▶ my ($self) = $_[OBJECT];
Subroutine _session_idle: not called CC=1 SCAR=6.9
108  
109 0 my $alias = $self->alias;
110  
111 0 $self->log->debug("$alias: session_idle()");
112  
113 0 $self->session_idle();
114  
115 }
116  
117 sub _session_pause {
118 0 ▶ my ($self) = $_[OBJECT];
Subroutine _session_pause: not called CC=1 SCAR=6.9
119  
120 0 my $alias = $self->alias;
121  
122 0 $self->log->debug("$alias: session_pause()");
123  
124 0 $self->session_pause();
125  
126 }
127  
128 sub _session_resume {
129 0 ▶ my ($self) = $_[OBJECT];
Subroutine _session_resume: not called CC=1 SCAR=6.9
130  
131 0 my $alias = $self->alias;
132  
133 0 $self->log->debug("$alias: _session_resume()");
134  
135 0 $self->session_resume();
136  
137 }
138  
139 sub _session_status {
140 0 ▶ my ($self, $status) = @_[OBJECT, ARG0];
Subroutine _session_status: not called CC=1 SCAR=6.9
141  
142 0 my $alias = $self->alias;
143  
144 0 $self->log->debug("$alias: _session_status()");
145  
146 0 $self->session_status($status);
147  
148 }
149  
150 1 1;
151  
152 __END__
153  
154 =head1 NAME
155  
156 XAS::Lib::POE::Service - The base class for service sessions.
157  
158 =head1 SYNOPSIS
159  
160 my $session = XAS::Lib::POE::Service->new(
161 -alias => 'name',
162 );
163  
164 =head1 DESCRIPTION
165  
166 This module inherits and extends L<XAS::Lib::POE::Session|XAS::Lib::POE::Session>.
167 It adds several more event types that can be signaled from registered
168 sessions with L<XAS::Lib::Service|XAS::Lib::Service>.
169  
170 The method session_initialize() is used to define this event types:
171  
172 session_idle
173 session_pause
174 session_resume
175 session_status
176  
177 While signal processing for HUP is not changed.
178  
179 =head1 METHODS
180  
181 =head2 session_idle
182  
183 This mehod is called during the sessions idle time. The idle time is defined
184 in L<XAS::Lib::Service|XAS::Lib::Service>.
185  
186 =head2 session_pause
187  
188 This method is called when the service has been requested to pause processing.
189  
190 =head2 session_resume
191  
192 This method is called when the service has been requested to resume processing.
193  
194 =head2 session_status
195  
196 This method returns the status of the session.
197  
198 =head1 SEE ALSO
199  
200 =over 4
201  
202 =item L<XAS|XAS>
203  
204 =item L<XAS::Lib::Service|XAS::Lib::Service>
205  
206 =back
207  
208 =head1 AUTHOR
209  
210 Kevin L. Esteb, E<lt>kevin@kesteb.usE<gt>
211  
212 =head1 COPYRIGHT AND LICENSE
213  
214 Copyright (C) 2014 Kevin L. Esteb
215  
216 This is free software; you can redistribute it and/or modify it under
217 the terms of the Artistic License 2.0. For details, see the full text
218 of the license at http://www.perlfoundation.org/artistic_license_2_0.
219  
220 =cut
« blib/lib/XAS/Lib/App/Service/Unix.pm ↑ Summary blib/lib/XAS/Lib/App.pm »