Zing/Worker.pm untested

filter: Statementstmt 0.0% 0 / 26 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod n/a totaltotal 0.0% 0 / 33 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Zing::Worker;
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  
13 use Zing::Logic::Worker;
14  
15 extends 'Zing::Process';
16  
17 our $VERSION = '0.26'; # VERSION
18  
19 # BUILDERS
20  
21 fun new_logic($self) {
22 my $debug = $self->env->debug;
23 Zing::Logic::Worker->new(debug => $debug, process => $self)
24 }
25  
26 1;
27  
28 =encoding utf8
29  
30 =head1 NAME
31  
32 Zing::Worker - Worker Process
33  
34 =cut
35  
36 =head1 ABSTRACT
37  
38 Worker Process
39  
40 =cut
41  
42 =head1 SYNOPSIS
43  
44 package MyApp;
45  
46 use parent 'Zing::Worker';
47  
48 sub handle {
49 my ($name, $data) = @_;
50  
51 [$name, $data];
52 }
53  
54 sub perform {
55 time;
56 }
57  
58 sub queues {
59 ['todos'];
60 }
61  
62 sub receive {
63 my ($self, $from, $data) = @_;
64  
65 [$from, $data];
66 }
67  
68 package main;
69  
70 my $myapp = MyApp->new;
71  
72 # $myapp->execute;
73  
74 =cut
75  
76 =head1 DESCRIPTION
77  
78 This package provides a L<Zing::Process> which listens to one or more queues
79 calls the C<handle> method for each new message received. The standard process
80 C<perform> and C<receive> methods operate as expected.
81  
82 =cut
83  
84 =head1 INHERITS
85  
86 This package inherits behaviors from:
87  
88 L<Zing::Process>
89  
90 =cut
91  
92 =head1 LIBRARIES
93  
94 This package uses type constraints from:
95  
96 L<Zing::Types>
97  
98 =cut
99  
100 =head1 SCENARIOS
101  
102 This package supports the following scenarios:
103  
104 =cut
105  
106 =head2 handle
107  
108 # given: synopsis
109  
110 $myapp->handle('todos', { todo => 'rebuild' });
111  
112 The handle method is meant to be implemented by a subclass and is
113 automatically invoked when a message is received from a defined queue.
114  
115 =cut
116  
117 =head2 perform
118  
119 # given: synopsis
120  
121 $myapp->perform;
122  
123 The perform method is meant to be implemented by a subclass and is
124 automatically invoked iteratively by the event-loop.
125  
126 =cut
127  
128 =head2 queues
129  
130 # given: synopsis
131  
132 $myapp->queues;
133  
134 The queues method is meant to be implemented by a subclass and is automatically
135 invoked when the process is executed.
136  
137 =cut
138  
139 =head2 receive
140  
141 # given: synopsis
142  
143 $myapp->receive($myapp->name, { status => 'ok' });
144  
145 The receive method is meant to be implemented by a subclass and is
146 automatically invoked iteratively by the event-loop.
147  
148 =cut
149  
150 =head1 AUTHOR
151  
152 Al Newkirk, C<awncorp@cpan.org>
153  
154 =head1 LICENSE
155  
156 Copyright (C) 2011-2019, Al Newkirk, et al.
157  
158 This is free software; you can redistribute it and/or modify it under the terms
159 of the The Apache License, Version 2.0, as elucidated in the L<"license
160 file"|https://github.com/iamalnewkirk/zing/blob/master/LICENSE>.
161  
162 =head1 PROJECT
163  
164 L<Wiki|https://github.com/iamalnewkirk/zing/wiki>
165  
166 L<Project|https://github.com/iamalnewkirk/zing>
167  
168 L<Initiatives|https://github.com/iamalnewkirk/zing/projects>
169  
170 L<Milestones|https://github.com/iamalnewkirk/zing/milestones>
171  
172 L<Contributing|https://github.com/iamalnewkirk/zing/blob/master/CONTRIBUTE.md>
173  
174 L<Issues|https://github.com/iamalnewkirk/zing/issues>
175  
176 =cut