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