Zing::Timer - Timer Process
Timer Process
package MyApp; use parent 'Zing::Timer'; sub schedules { [ # every ten minutes ['*/10 * * * *', ['tasks'], { do => 1 }], ] } package main; my $myapp = MyApp->new; # $myapp->execute;
This package provides a Zing::Process which places pre-defined messages into message queues based on time-based scehdules. It supports minute-level resolution and functions similarly to a crontab (cron table).
This package inherits behaviors from:
Zing::Process
This package uses type constraints from:
Zing::Types
This package supports the following scenarios:
# given: synopsis $myapp->schedules; # schedule structure # [$interval, $queues, $message, $adjustment] # predefined intervals # @annually is at 00:00 on day-of-month 1 in january # @daily is at 00:00 every day # @hourly is at minute 0 every hour # @minute is at every minute # @monthly is at 00:00 on day-of-month 1 # @weekend is at 00:00 on saturday # @weekly is at 00:00 on monday # @yearly is at 00:00 on day-of-month 1 in january # other schedule examples # every minute # ['* * * * *', ['tasks'], { do => 1 }] # every hour (on the half hour) # ['30 * * * *', ['tasks'], { do => 1 }] # every 15th minute # ['*/15 * * * *', ['tasks'], { do => 1 }]
The schedules method is meant to be implemented by a subclass and is automatically invoked when the process is executed, it should return a list of schedules. A single schedule takes the form of [$interval, $queues, $message] where $interval is represented as a cron-expression or using one of the predefined interval name, e.g. @yearly, @annually, @monthly, @weekly, @weekend, @daily, @hourly, or @minute.
[$interval, $queues, $message]
$interval
@yearly
@annually
@monthly
@weekly
@weekend
@daily
@hourly
@minute
This package has the following attributes:
on_schedules(Maybe[CodeRef])
This attribute is read-only, accepts (Maybe[CodeRef]) values, and is optional.
(Maybe[CodeRef])
This package implements the following methods:
schedules(Any @args) : ArrayRef[Schedule]
The schedules method, when not overloaded, executes the callback in the "on_schedules" attribute and expects a list of crontab schedules to be processed.
my $timer = Zing::Timer->new( on_schedules => sub { [['@hourly', ['tasks'], { do => 1 }]] }, ); $timer->schedules;
Al Newkirk, awncorp@cpan.org
awncorp@cpan.org
Copyright (C) 2011-2019, Al Newkirk, et al.
This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".
Wiki
Project
Initiatives
Milestones
Contributing
Issues
To install Zing, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Zing
CPAN shell
perl -MCPAN -e shell install Zing
For more information on module installation, please visit the detailed CPAN module installation guide.