Zing/Worker.pm untested

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