maintenance

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2026 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL