Documentation
¶
Overview ¶
Package schedule runs Eraser's send + inbox cycle unattended: the OS scheduler (launchd, systemd) when installed, otherwise an in-process loop. All modes share one lock so two cycles never overlap.
Index ¶
- Constants
- func Install(j Job) error
- func Installed() bool
- func NextOSRun(now time.Time) time.Time
- func Remove() error
- func SaveState(dir string, s State) error
- func StableExecutable() (string, error)
- func Supported() bool
- func TryLock(dir string) (release func(), ok bool, err error)
- func UnderOSJob() bool
- type Job
- type State
Constants ¶
const Every = "every 6 hours"
Every describes Interval for messages.
const Interval = 6 * time.Hour
Interval is how often cycles run, in every mode. Six hours rather than daily: the send cap is a rolling 24h window, so a run exactly 24h after the last one still sees that run's sends inside the window and sends nothing. Runs with nothing due are cheap no-ops.
Variables ¶
This section is empty.
Functions ¶
func Installed ¶
func Installed() bool
Installed reports whether the OS job is set up. False on unsupported platforms.
func Remove ¶
func Remove() error
Remove unloads and deletes the OS job. Removing a job that isn't installed is not an error.
func StableExecutable ¶
StableExecutable is the path the OS job should run. It prefers the eraser on PATH (e.g. Homebrew's symlink, which survives upgrades) when that's the same binary as this one, and refuses a 'go run' temp build.
func Supported ¶
func Supported() bool
Supported reports whether Install can set up an OS job on this platform.
func TryLock ¶
TryLock takes the cycle lock in dir (the config directory). ok is false when another cycle holds it. The OS releases the lock if the process dies, so there are no stale lock files to clean up.
func UnderOSJob ¶
func UnderOSJob() bool
UnderOSJob reports whether this process was started by the OS job, from the environment launchd and systemd set for their services.
Types ¶
type Job ¶
type Job struct {
Exe string
ConfigPath string
LogPath string // launchd only; systemd logs to the journal
}
Job is what the OS scheduler runs: `<Exe> auto --once --config <ConfigPath>`.
type State ¶
type State struct {
LastRun time.Time `json:"last_run"`
Mode string `json:"mode"` // "os", "loop", "once", "serve"
Sent int `json:"sent"`
Error string `json:"error,omitempty"`
}
State is the outcome of the last cycle, written by every mode so `eraser schedule status` and the web UI can show it.