Documentation
¶
Overview ¶
Package schedule reads a window of a workload's schedule (the router's lambda/src/lib/schedule.mjs), for `dormeto aws schedule` and `dormeto gcp schedule`: a recurrence in the dashboard's words; and changes a schedule window by window (edit.go). The router checks a schedule; nothing here does.
Index ¶
- Constants
- Variables
- func CheckDate(flag, value string) error
- func CheckTime(flag, value string) error
- func JoinGap(minutes int) string
- func JoinText(minutes int) string
- func ParseJoinMinutes(s string) (*int, error)
- func RefusedAsEmpty(message string) bool
- func RefusedAsUnknown(message string) bool
- func Windows(raw json.RawMessage) int
- type Change
- type Exceptions
- type Join
- type NewRepeat
- type NewWindow
- type Window
Constants ¶
const JoinDefault = 15
JoinDefault is the largest gap that joins two windows when no level sets it.
const LastWindowHint = "that was its last window: schedule clear removes the schedule"
LastWindowHint is what a refused removal of a schedule's last window adds: the router may refuse a schedule left with nothing, and clear removes it.
const RecurrenceRouter = "0.36.0"
RecurrenceRouter is the first router that takes repeat, from, until, a window's exceptions and joinMinutes.
Variables ¶
var ErrNoSchedule = errors.New("no schedule: schedule add makes one")
ErrNoSchedule is a change that needs a schedule, of a workload that has none.
Functions ¶
func CheckDate ¶ added in v0.15.0
CheckDate refuses a flag's value that is not a calendar date YYYY-MM-DD.
func CheckTime ¶ added in v0.15.0
CheckTime refuses a flag's value that is not a time of day HH:MM (which minutes the router takes is its to say).
func ParseJoinMinutes ¶
ParseJoinMinutes reads a --join-minutes value: a whole number from 0 to 120, a multiple of 5, or inherit (nil).
func RefusedAsEmpty ¶ added in v0.15.0
RefusedAsEmpty says a router's refusal is of a schedule left with nothing: no window and no maximum nap.
func RefusedAsUnknown ¶
RefusedAsUnknown says a router's refusal is a router older than RecurrenceRouter's: it names repeat, from, until, a window's exceptions or joinMinutes as unknown. A router that has them only says that of a field inside repeat.
func Windows ¶ added in v0.15.0
func Windows(raw json.RawMessage) int
Windows is the number of windows of a schedule, 0 for none.
Types ¶
type Change ¶ added in v0.15.0
type Change struct {
Add *NewWindow
TimeZone string
Remove int
Except *Exceptions
Fields map[string]json.RawMessage
}
Change is one change of a schedule, as the commands' flags say it: one of Add (with TimeZone, the zone of a first schedule), Remove (a window's number, from 1), Except, or Fields (edit: each member set to its value, or removed when nil).
func (Change) Apply ¶ added in v0.15.0
func (c Change) Apply(raw json.RawMessage) (json.RawMessage, error)
Apply is the schedule raw (the router's answer; empty or null for none) with the change, every other member as it was.
type Exceptions ¶ added in v0.15.0
Exceptions are dates without a window that `schedule except` adds, or takes out with Remove: the schedule's (Window 0) or one window's (its number, from 1).
type Join ¶
type Join struct {
JoinMinutes json.RawMessage `json:"joinMinutes,omitempty"`
JoinFrom json.RawMessage `json:"joinFrom,omitempty"`
JoinInherited json.RawMessage `json:"joinInherited,omitempty"`
}
Join is what a router's status and schedule answers add beside the schedule: the value in force, its level and what removing the workload's own would give. Raw, so it goes through --json as answered, 0 included, and an older router's answer adds nothing.
type NewRepeat ¶ added in v0.15.0
type NewRepeat struct {
Pattern string `json:"pattern"`
Interval *int `json:"interval,omitempty"`
Days []string `json:"days,omitempty"`
Day *int `json:"day,omitempty"`
Nth *int `json:"nth,omitempty"`
Weekday string `json:"weekday,omitempty"`
Cron string `json:"cron,omitempty"`
Minutes *int `json:"minutes,omitempty"`
}
NewRepeat is a new window's repeat: its pattern and the members the flags gave.
type NewWindow ¶ added in v0.15.0
type NewWindow struct {
Kind string `json:"kind"`
Days []string `json:"days,omitempty"`
Start string `json:"start,omitempty"`
End string `json:"end,omitempty"`
Repeat *NewRepeat `json:"repeat,omitempty"`
From string `json:"from,omitempty"`
Until string `json:"until,omitempty"`
Wake string `json:"wake,omitempty"`
}
NewWindow is a window `schedule add` appends, its members the router's (lib/schedule.mjs); an empty one is left out.
type Window ¶
type Window struct {
Kind string `json:"kind"`
Days []string `json:"days"`
Start string `json:"start"`
End string `json:"end"`
Repeat json.RawMessage `json:"repeat"`
From string `json:"from"`
Until string `json:"until"`
Wake string `json:"wake"`
Exceptions []string `json:"exceptions"`
}
Window is a window as the router stores it. Repeat stays raw until it is read: a stored one that does not read has no occurrence and raises no error, so it cannot fail the decoding of the schedule around it. null on a field is its absence. Exceptions are the window's own dates without it (router 0.36.0); the schedule's skip every window.
func (Window) FarReach ¶
FarReach is a window that takes the router's next events as far as 400 days: a repeat or a from; an until alone does not.