schedule

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 8 Imported by: 0 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 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

View Source
const JoinDefault = 15

JoinDefault is the largest gap that joins two windows when no level sets it.

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

View Source
const RecurrenceRouter = "0.36.0"

RecurrenceRouter is the first router that takes repeat, from, until, a window's exceptions and joinMinutes.

Variables

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

func CheckDate(flag, value string) error

CheckDate refuses a flag's value that is not a calendar date YYYY-MM-DD.

func CheckTime added in v0.15.0

func CheckTime(flag, value string) error

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 JoinGap

func JoinGap(minutes int) string

JoinGap is "up to 15 min apart", or "never" for 0.

func JoinText

func JoinText(minutes int) string

JoinText is "join windows up to 15 min apart", or "windows never join" for 0.

func ParseJoinMinutes

func ParseJoinMinutes(s string) (*int, error)

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

func RefusedAsEmpty(message string) bool

RefusedAsEmpty says a router's refusal is of a schedule left with nothing: no window and no maximum nap.

func RefusedAsUnknown

func RefusedAsUnknown(message string) bool

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

type Exceptions struct {
	Dates  []string
	Window int
	Remove bool
}

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.

func (Join) Line

func (j Join) Line() string

Line is "join windows up to 15 min apart (organization)" or "windows never join (workload)", "" without a value.

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

func (w Window) FarReach() bool

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.

func (Window) Plain

func (w Window) Plain() bool

Plain is a window with only weekly days and times, as there were before recurrences.

func (Window) Text

func (w Window) Text() string

Text is the window's recurrence in words, without its kind and wake mode: "Every 2 weeks on Mon, Thu, 20:00–07:00 next day, from 2027-01-04, no end date", "Monthly on day 15, 08:00–18:00", "Cron 30 8 * * 1-5, 10 h 30 min".

Jump to

Keyboard shortcuts

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