~sircmpwn/scheduled

scheduled/schedule/schedule.ha -rw-r--r-- 1.5 KiB
1db951c7Sebastian Makefile: add all to .PHONY target 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use datetime;
use time::chrono;

// Each schedule includes a set of settings to configure parameters like error
// emails, as well as a list of scheduled tasks.
export type schedule = struct {
	settings: settings,
	items: []item,
};

// A mailbox includes an optional recipient name (or empty string) and a
// mailbox, e.g. ("Drew DeVault", "sir@cmpwn.com").
//
// TODO: Move this to the stdlib
export type mailbox = (str, str);

// Configuration settings that apply to a schedule.
export type settings = struct {
	// The time zone this schedule is configured to use
	zone: chrono::timezone,
	// Who the failure emails should be sent from
	mailfrom: mailbox,
	// Who to send failure emails to
	mailto: []mailbox,
	// Size of the ring buffer to use for stdout/stderr capture for error
	// emails
	bufsz: size,
	// Which user/group to run this schedule as
	uid: (uint | void),
	gid: (uint | void),
};

// Units for event repetition.
export type repeat = enum {
	ONCE,
	MINUTE,
	HOUR,
	DAY,
	WEEK,
	MONTH,
	QUARTER,
	YEAR,
};

// A single scheduled task.
export type item = struct {
	// When this event is scheduled for. Some fields may be left 'void' to
	// leave those parameters unconstrained.
	when: datetime::datetime,

	// The repeat configuration includes the period to use (e.g. daily) and
	// how many of those should pass between events (e.g. every 3 days), or
	// zero for events that do not repeat.
	repeat: (int, repeat),

	// The command to execute when the scheduled task is due.
	command: str,
};