cleaned up demo scripts locations
[urisagit/Stem.git] / Design / cron_notes
CommitLineData
4536f655 1
2 Stem Cron System Design Notes
3
4Stem::Cron is designed to both supplant the standard OS cron and
5extending it to support more useful time filters. The key difference
6from the OS cron is that Stem::Cron sends a Stem message when it is
7triggered instead of running a process. This message can be addressed to
8any cell on any Stem hub and so it can cause any action to occur. To
9emulate the OS cron, all the message needs to do is to trigger an
10addressed Stem::Proc cell to spawn a process.
11
12
13
14Stem::Cron entries are similar to the OS cron. You can select a set of
15time parts (minutes, hours, dates, months, days of week) to trigger the
16entry and each part is a list which filters the triggers. Each minute
17(run by infinite repeat timer) the list of cron entries is scanned. If
18the current broken out time matches one corresponding value in each of
19the parts of the entry, then the entry is triggered and its message
20is dispatched.
21
22The cron entry is configured with name/value pairs which are the time
23parts and the set of which values to trigger on in that part. If a time
24is not specified, it is assumed to match all values for that time part
25(like * in crontab). These two differences already make Stem::Cron
26easier to configure than crontab. In addition, each Stem::Cron entry
27must have a message value. This is sent when the cron entry passes all
28of its time filters and gets triggered. The message can be any type,
29carry any data and be addressed to any cell in the Stem network.
30
31Beyond the simple time filters of crontab, Stem::Cron allows you to
32specify complex date descriptions such as last date of the month, first
33weekday of the month, 2nd Thursday of the month, etc.
34
35Another feature I am looking at is not well defined but i have a use for
36it. The log filters want to have a time based toggle so for example, you
37can enable/disable sending logs to a pager at night by sending it the
38right messages. By attaching those messages to properly configured cron
39entries, you have automated managing the times when the log filter is
40enabled/disabled. But there are several open design issues. First, what
41is the initial boolean state of the log time filter? Maybe we should make
42another boolean attribute: time_filter_enabled => 1. Then how often do
43you send the boolean toggle messages? A normal cron time range would
44send messages every minute from enable to disable time (huh?). or we can
45just send the disable message on one tightly defined cron entry and the
46enable on another. The initial boolean state is used and that will keep
47the log filter in the right state. This time controlled boolean toggle
48is a useful idea we can apply elsewhere. A module just for managing
49these things could be a good idea. It would, of course, use Stem::Cron,
50but it could be specialized in setting the cron entries up and other
51stuff.
52
53Right now, Stem::Cron entries are only created in configuration
54files. Creating remote entries would just require sending a config via a
55message to the global Cron cell.
56
57Stem::Cron is a high-level layer above Stem::Event timers. The major
58difference is that Stem::Event only uses callbacks, whereas
59Stem::Cron only sends out messages. Also, Stem::Cron has a much more
60powerful and flexible API for specifying the timing of these messages.
61
62Besides the emulation of the standard OS cron, Stem::Cron can send
63out a message at a repeated interval which has a resolution of
64seconds.
65
66TODO
67
68more testing
69
70fancy time parts. i have developed perl code that calculates most of
71those dates so it should be simple to port the logic over to stem.
72
73timed boolean triggers needs more design work and then coding.
74
75Sending remote configs has not been developed yet but should be done
76soon. should be generic and go into the Stem::Config module.
77
78
79
80