Zing/Timer.pm

filter: Statementstmt 88.8% 24 / 27 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 7 / 8 Podpod 0.0% 0 / 1 totaltotal 86.1% 31 / 36 CC 1 SCAR 1.2
CC
1
Cov
89%
new_logic
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Zing/Single.pm ↑ Summary Zing/Types.pm »
1 package Zing::Timer;
2  
3 49 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 49 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 49 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 49 ▶use registry 'Zing::Types';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 49 ▶use routines;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 49 ▶use Data::Object::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 49 ▶use Zing::Logic::Timer;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 49 extends 'Zing::Process';
15  
16 49 our $VERSION = '0.11'; # VERSION
17  
18 # BUILDERS
19  
20 0 ▶fun new_logic($self) {
Subroutine new_logic: not called CC=1 SCAR=6.9
Pod undocumented
21 0 Zing::Logic::Timer->new(process => $self)
22 49 }
23  
24 49 1;
25  
26 =encoding utf8
27  
28 =head1 NAME
29  
30 Zing::Timer - Timer Process
31  
32 =cut
33  
34 =head1 ABSTRACT
35  
36 Timer Process
37  
38 =cut
39  
40 =head1 SYNOPSIS
41  
42 package MyApp;
43  
44 use parent 'Zing::Timer';
45  
46 sub schedules {
47 [
48 # every ten minutes
49 ['*/10 * * * *', ['tasks'], { do => 1 }],
50 ]
51 }
52  
53 package main;
54  
55 my $myapp = MyApp->new;
56  
57 # $myapp->execute;
58  
59 =cut
60  
61 =head1 DESCRIPTION
62  
63 This package provides a L<Zing::Process> which places pre-defined messages into
64 message queues based on time-based scehdules. It supports minute-level
65 resolution and functions similarly to a crontab (cron table).
66  
67 =cut
68  
69 =head1 INHERITS
70  
71 This package inherits behaviors from:
72  
73 L<Zing::Process>
74  
75 =cut
76  
77 =head1 LIBRARIES
78  
79 This package uses type constraints from:
80  
81 L<Zing::Types>
82  
83 =cut
84  
85 =head1 SCENARIOS
86  
87 This package supports the following scenarios:
88  
89 =cut
90  
91 =head2 schedules
92  
93 # given: synopsis
94  
95 $myapp->schedules;
96  
97 # schedule structure
98 # [$interval, $queues, $message, $adjustment]
99  
100 # predefined schedules
101  
102 # @annually is at 00:00 on day-of-month 1 in january
103 # @daily is at 00:00 every day
104 # @hourly is at minute 0 every hour
105 # @minute is at every minute
106 # @monthly is at 00:00 on day-of-month 1
107 # @weekend is at 00:00 on saturday
108 # @weekly is at 00:00 on monday
109 # @yearly is at 00:00 on day-of-month 1 in january
110  
111 # other schedule examples
112  
113 # every minute
114 # ['* * * * *', ['tasks'], { do => 1 }]
115  
116 # every hour (on the half hour)
117 # ['30 * * * *', ['tasks'], { do => 1 }]
118  
119 # every 15th minute
120 # ['*/15 * * * *', ['tasks'], { do => 1 }]
121  
122 The schedules method is meant to be implemented by a subclass and is
123 automatically invoked when the process is executed, it should return a list of
124 schedules. A single schedule takes the form of C<[$interval, $queues,
125 $message]> where C<$interval> is represented as a cron-expression or using one
126 of the predefined interval name, e.g. C<@yearly>, C<@annually>, C<@monthly>,
127 C<@weekly>, C<@weekend>, C<@daily>, C<@hourly>, or C<@minute>.
128  
129 =cut
130  
131 =head1 AUTHOR
132  
133 Al Newkirk, C<awncorp@cpan.org>
134  
135 =head1 LICENSE
136  
137 Copyright (C) 2011-2019, Al Newkirk, et al.
138  
139 This is free software; you can redistribute it and/or modify it under the terms
140 of the The Apache License, Version 2.0, as elucidated in the L<"license
141 file"|https://github.com/iamalnewkirk/zing/blob/master/LICENSE>.
142  
143 =head1 PROJECT
144  
145 L<Wiki|https://github.com/iamalnewkirk/zing/wiki>
146  
147 L<Project|https://github.com/iamalnewkirk/zing>
148  
149 L<Initiatives|https://github.com/iamalnewkirk/zing/projects>
150  
151 L<Milestones|https://github.com/iamalnewkirk/zing/milestones>
152  
153 L<Contributing|https://github.com/iamalnewkirk/zing/blob/master/CONTRIBUTE.md>
154  
155 L<Issues|https://github.com/iamalnewkirk/zing/issues>
156  
157 =cut
« Zing/Single.pm ↑ Summary Zing/Types.pm »