Documentation
¶
Overview ¶
Package maintenance hosts the canonical parser, validator, union resolver and evaluator for pm.v1.MaintenanceWindow. The package is shared so server (handler validation, union computation across the device's groups) and agent (per-tick gate in the scheduler) agree bit-for-bit on what counts as an allowed dispatch time.
Window semantics:
- Empty schedule = "always allowed". The feature is opt-in and a group with no window contributes nothing to the device-side gate.
- Each entry is (weekdays, allow-range). The allow-range uses 24-hour HH:MM-HH:MM. start > end means the range crosses midnight and continues into the next weekday.
- Multiple entries combine as OR within a single window: any matching entry allows the moment.
- Union across windows applies the same OR. The device is allowed when *any* of its reaching groups allows the moment. If any reaching group is empty, the union collapses to "always allowed" — empty already means unconstrained, so adding it to the union cannot tighten the result.
All evaluation runs against time.Time.Local at the agent. The server never computes IsAllowed — the device is the only authority on its own wall-clock.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidEntry = errors.New("invalid maintenance window entry")
ErrInvalidEntry is returned by Validate when the schedule contains a malformed entry. Callers wrap this in a Connect-RPC CodeInvalidArgument so the web UI can surface a precise message.
Functions ¶
func IsAllowed ¶
func IsAllowed(w *pmv1.MaintenanceWindow, t time.Time) bool
IsAllowed reports whether the moment t falls inside the window. A nil window or empty schedule allows every moment. The check uses t.Weekday() and t.Hour()/t.Minute() — callers that want device-local semantics must pass an already-Local'd time.
func Union ¶
func Union(windows ...*pmv1.MaintenanceWindow) *pmv1.MaintenanceWindow
Union combines windows the most-permissive way: if any input is empty (nil or zero schedule), the result is empty (= always allowed). Otherwise the result is the concatenation of every input's entries — IsAllowed already ORs entries within a single window, so concatenation gives OR across windows for free.
The returned window aliases input entry pointers; callers that mutate the result must clone first. Server-side resolvers don't mutate, so the alias is safe in practice.
func Validate ¶
func Validate(w *pmv1.MaintenanceWindow) error
Validate reports whether the window is syntactically well-formed. A nil window or an empty schedule is valid (= always allowed).
Types ¶
This section is empty.