Zing/Logic/Kernel.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod n/a totaltotal 0.0% 0 / 53 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Zing::Logic::Kernel;
2  
3 use 5.014;
4  
5 use strict;
6 use warnings;
7  
8 use registry 'Zing::Types';
9 use routines;
10  
11 use Data::Object::Class;
12 use Data::Object::ClassHas;
13  
14 extends 'Zing::Logic::Watcher';
15  
16 our $VERSION = '0.11'; # VERSION
17  
18 # METHODS
19  
20 method flow() {
21 my $step_0 = $self->next::method;
22  
23 my $step_1 = Zing::Flow->new(
24 name => 'on_purge',
25 code => fun($step, $loop) { $self->trace('handle_purge_event') }
26 );
27  
28 $step_0->append($step_1);
29 $step_0
30 }
31  
32 method handle_purge_event() {
33 my $process = $self->process;
34  
35 return $self if !$process->can('journal');
36  
37 # check every minute (60 secs) not every tick
38 if ($self->{purge_at}) {
39 return $self if $self->{purge_at} > time;
40 }
41 else {
42 $self->{purge_at} = time+60;
43 return $self;
44 }
45  
46 $process->journal->drop if $process->journal->size > 10_000;
47  
48 $self->{purge_at} = time+60;
49  
50 return $self;
51 }
52  
53 1;
54  
55 =encoding utf8
56  
57 =head1 NAME
58  
59 Zing::Logic::Kernel - Kernel Logic
60  
61 =cut
62  
63 =head1 ABSTRACT
64  
65 Kernel Process Logic Chain
66  
67 =cut
68  
69 =head1 SYNOPSIS
70  
71 use Zing::Kernel;
72 use Zing::Logic::Kernel;
73  
74 my $logic = Zing::Logic::Kernel->new(
75 process => Zing::Kernel->new(
76 scheme => ['MyApp', [], 1]
77 )
78 );
79  
80 # $logic->execute;
81  
82 =cut
83  
84 =head1 DESCRIPTION
85  
86 This package provides the logic (or logic chain) to be executed by the kernel
87 process event-loop.
88  
89 =cut
90  
91 =head1 INHERITS
92  
93 This package inherits behaviors from:
94  
95 L<Zing::Logic::Watcher>
96  
97 =cut
98  
99 =head1 LIBRARIES
100  
101 This package uses type constraints from:
102  
103 L<Zing::Types>
104  
105 =cut
106  
107 =head1 ATTRIBUTES
108  
109 This package has the following attributes:
110  
111 =cut
112  
113 =head2 interupt
114  
115 interupt(Interupt)
116  
117 This attribute is read-only, accepts C<(Interupt)> values, and is optional.
118  
119 =cut
120  
121 =head2 on_perform
122  
123 on_perform(CodeRef)
124  
125 This attribute is read-only, accepts C<(CodeRef)> values, and is optional.
126  
127 =cut
128  
129 =head2 on_receive
130  
131 on_receive(CodeRef)
132  
133 This attribute is read-only, accepts C<(CodeRef)> values, and is optional.
134  
135 =cut
136  
137 =head2 on_register
138  
139 on_register(CodeRef)
140  
141 This attribute is read-only, accepts C<(CodeRef)> values, and is optional.
142  
143 =cut
144  
145 =head2 on_reset
146  
147 on_reset(CodeRef)
148  
149 This attribute is read-only, accepts C<(CodeRef)> values, and is optional.
150  
151 =cut
152  
153 =head2 on_suicide
154  
155 on_suicide(CodeRef)
156  
157 This attribute is read-only, accepts C<(CodeRef)> values, and is optional.
158  
159 =cut
160  
161 =head2 process
162  
163 process(Process)
164  
165 This attribute is read-only, accepts C<(Process)> values, and is required.
166  
167 =cut
168  
169 =head1 METHODS
170  
171 This package implements the following methods:
172  
173 =cut
174  
175 =head2 flow
176  
177 flow() : Flow
178  
179 The flow method builds and returns the logic flow for the process event-loop.
180  
181 =over 4
182  
183 =item flow example #1
184  
185 # given: synopsis
186  
187 my $flow = $logic->flow;
188  
189 =back
190  
191 =cut
192  
193 =head2 signals
194  
195 signals() : HashRef
196  
197 The signals method builds and returns the process signal handlers.
198  
199 =over 4
200  
201 =item signals example #1
202  
203 # given: synopsis
204  
205 my $signals = $logic->signals;
206  
207 =back
208  
209 =cut
210  
211 =head1 AUTHOR
212  
213 Al Newkirk, C<awncorp@cpan.org>
214  
215 =head1 LICENSE
216  
217 Copyright (C) 2011-2019, Al Newkirk, et al.
218  
219 This is free software; you can redistribute it and/or modify it under the terms
220 of the The Apache License, Version 2.0, as elucidated in the L<"license
221 file"|https://github.com/iamalnewkirk/zing/blob/master/LICENSE>.
222  
223 =head1 PROJECT
224  
225 L<Wiki|https://github.com/iamalnewkirk/zing/wiki>
226  
227 L<Project|https://github.com/iamalnewkirk/zing>
228  
229 L<Initiatives|https://github.com/iamalnewkirk/zing/projects>
230  
231 L<Milestones|https://github.com/iamalnewkirk/zing/milestones>
232  
233 L<Contributing|https://github.com/iamalnewkirk/zing/blob/master/CONTRIBUTE.md>
234  
235 L<Issues|https://github.com/iamalnewkirk/zing/issues>
236  
237 =cut