schedule

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 6 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 evaluates whether the daemon should be active at a given instant, combining the configured weekly windows with any manual override.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Active

func Active(cfg config.Config, t time.Time) bool

Active reports whether the configured schedule (ignoring overrides) is active at time t. The instant is evaluated in the config's timezone.

func DesiredActive

func DesiredActive(cfg config.Config, ov Override, t time.Time) bool

DesiredActive applies the override on top of the schedule and returns the effective desired state at time t. An expired override is ignored.

func NextChange

func NextChange(cfg config.Config, ov Override, t time.Time) (when time.Time, toActive bool, ok bool)

NextChange scans forward from t (up to ~14 days) and returns the next instant at which DesiredActive flips, plus the state it flips to. ok is false if no change is found within the horizon (e.g. an indefinite override or 24/7).

func SaveOverride

func SaveOverride(path string, o Override) error

SaveOverride atomically writes the override to path.

Types

type Override

type Override struct {
	Mode  OverrideMode `json:"mode"`
	Until *time.Time   `json:"until,omitempty"`
	SetAt time.Time    `json:"set_at"`
}

Override is the persisted manual override. A nil Until is indefinite.

func LoadOverride

func LoadOverride(path string) (Override, error)

LoadOverride reads override.json. A missing file yields a zero (None) override and no error.

func (Override) Active

func (o Override) Active(t time.Time) bool

Active reports whether the override is currently in force at t.

func (Override) EffectiveMode

func (o Override) EffectiveMode(t time.Time) OverrideMode

EffectiveMode returns the override mode in force at time t, treating an expired (Until <= t) override as OverrideNone.

type OverrideMode

type OverrideMode string

OverrideMode is a manual override of the schedule.

const (
	// OverrideNone means "follow the schedule".
	OverrideNone OverrideMode = ""
	// OverrideOn forces the daemon active.
	OverrideOn OverrideMode = "on"
	// OverrideOff forces the daemon inactive.
	OverrideOff OverrideMode = "off"
)

Jump to

Keyboard shortcuts

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