scheduler

package
v0.3.0 Latest Latest
Warning

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

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

View Source
const (
	SystemdService = "skillcrew-sync.service"
	SystemdTimer   = "skillcrew-sync.timer"
)

Systemd unit names.

View Source
const LaunchdLabel = "co.yoandev.skillcrew.sync"

LaunchdLabel identifies the LaunchAgent.

Variables

View Source
var (
	// ErrUnsupported is returned by New on an OS without a supported scheduler.
	ErrUnsupported = errors.New("no user-level scheduler supported on this OS")
	// ErrUnavailable wraps an Install failure caused by the scheduler itself
	// not running (e.g. WSL2 without systemd); callers can warn and continue.
	ErrUnavailable = errors.New("user-level scheduler unavailable")
)

Functions

func ExecRunner

func ExecRunner(name string, args ...string) error

ExecRunner runs the command with os/exec, including its combined output in the error on failure.

Types

type Runner

type Runner func(name string, args ...string) error

Runner executes an external command (injected for tests).

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

func New(home string, run Runner) (Scheduler, error)

New returns the scheduler for the current OS: launchd on darwin, systemd user units on linux. Other OSes return ErrUnsupported.

func NewLaunchd

func NewLaunchd(home string, uid int, run Runner) Scheduler

NewLaunchd returns the macOS backend: a LaunchAgent in ~/Library/LaunchAgents loaded into the gui/<uid> domain.

func NewSystemd

func NewSystemd(home string, run Runner) Scheduler

NewSystemd returns the Linux backend: a oneshot service and a timer in ~/.config/systemd/user, managed with systemctl --user.

Jump to

Keyboard shortcuts

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