schedule

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 14 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 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

View Source
const Every = "every 6 hours"

Every describes Interval for messages.

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

func Install(j Job) error

Install writes and loads the OS job, replacing any earlier one.

func Installed

func Installed() bool

Installed reports whether the OS job is set up. False on unsupported platforms.

func NextOSRun

func NextOSRun(now time.Time) time.Time

NextOSRun is when the installed OS job next fires after now.

func Remove

func Remove() error

Remove unloads and deletes the OS job. Removing a job that isn't installed is not an error.

func SaveState

func SaveState(dir string, s State) error

func StableExecutable

func StableExecutable() (string, error)

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

func TryLock(dir string) (release func(), ok bool, err error)

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>`.

func NewJob

func NewJob(cfg *config.Config, configPath string) (Job, error)

NewJob checks that cfg can run unattended and builds the OS job for it. It refuses configs that would fail on every run.

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.

func LoadState

func LoadState(dir string) (*State, error)

LoadState returns nil, nil when no cycle has run yet.

Jump to

Keyboard shortcuts

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