Documentation
¶
Overview ¶
Package scheduler registers the fallback periodic sync with the OS user-level scheduler: launchd on macOS, systemd user units on Linux. No admin rights, no resident daemon.
Index ¶
Constants ¶
const ( SystemdService = "skillcrew-sync.service" SystemdTimer = "skillcrew-sync.timer" )
Systemd unit names.
const LaunchdLabel = "co.yoandev.skillcrew.sync"
LaunchdLabel identifies the LaunchAgent.
Variables ¶
var ( // ErrUnsupported is returned by New on an OS without a supported scheduler. ErrUnsupported = errors.New("no user-level scheduler supported on this OS") // not running (e.g. WSL2 without systemd); callers can warn and continue. ErrUnavailable = errors.New("user-level scheduler unavailable") )
Functions ¶
func ExecRunner ¶
ExecRunner runs the command with os/exec, including its combined output in the error on failure.
Types ¶
type Scheduler ¶
type Scheduler interface {
// Install writes the scheduler files and (re)loads them. It is
// idempotent: re-installing rewrites the files and reloads.
Install(bin string, interval time.Duration) error
// Uninstall unloads and removes the files; it succeeds if not installed.
Uninstall() error
// Installed reports whether the unit or plist file is present.
Installed() bool
}
Scheduler registers the periodic sync with the OS user-level scheduler.
func New ¶
New returns the scheduler for the current OS: launchd on darwin, systemd user units on linux. Other OSes return ErrUnsupported.
func NewLaunchd ¶
NewLaunchd returns the macOS backend: a LaunchAgent in ~/Library/LaunchAgents loaded into the gui/<uid> domain.
func NewSystemd ¶
NewSystemd returns the Linux backend: a oneshot service and a timer in ~/.config/systemd/user, managed with systemctl --user.