scheduler

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigVersion = 1

Variables

This section is empty.

Functions

func ApplyDefaults

func ApplyDefaults(cfg *Config)

func DefaultBinaries

func DefaultBinaries() []string

func EnabledJobNames

func EnabledJobNames(cfg Config) []string

func LastRecords

func LastRecords(records []RunRecord) map[string]RunRecord

func LegacyManifest

func LegacyManifest(binary string) (control.Manifest, bool)

func Load

func Load(path string) (Config, Paths, error)

func ParseEvery

func ParseEvery(value string) (time.Duration, error)

func Uninstall

func Uninstall(backend string) error

Types

type App

type App struct {
	ID          string            `json:"id"`
	Binary      string            `json:"binary"`
	DisplayName string            `json:"display_name,omitempty"`
	Manifest    *control.Manifest `json:"manifest,omitempty"`
	Legacy      bool              `json:"legacy,omitempty"`
	Found       bool              `json:"found"`
	Path        string            `json:"path,omitempty"`
	Error       string            `json:"error,omitempty"`
}

func Discover

func Discover(ctx context.Context, binaries []string) []App

type Config

type Config struct {
	Version int            `toml:"version" json:"version"`
	Runner  RunnerConfig   `toml:"runner" json:"runner"`
	Jobs    map[string]Job `toml:"jobs" json:"jobs"`
}

func DefaultConfig

func DefaultConfig() Config

type InstallOptions

type InstallOptions struct {
	ConfigPath string
	Every      string
	Backend    string
	DryRun     bool
	Executable string
	Paths      Paths
}

type InstallPlan

type InstallPlan struct {
	Backend string   `json:"backend"`
	Path    string   `json:"path,omitempty"`
	Command []string `json:"command,omitempty"`
	Content string   `json:"content,omitempty"`
}

func Install

func Install(opts InstallOptions) (InstallPlan, error)

func PlanInstall

func PlanInstall(opts InstallOptions) (InstallPlan, error)

type Job

type Job struct {
	Enabled bool     `toml:"enabled" json:"enabled"`
	Every   string   `toml:"every,omitempty" json:"every,omitempty"`
	Command []string `toml:"command" json:"command"`
	Repos   []string `toml:"repos,omitempty" json:"repos,omitempty"`
	WorkDir string   `toml:"work_dir,omitempty" json:"work_dir,omitempty"`
	Env     []string `toml:"env,omitempty" json:"env,omitempty"`
}

func DefaultJobForApp

func DefaultJobForApp(app App, repos []string) (Job, bool)

type Paths

type Paths struct {
	ConfigPath string
	BaseDir    string
	LogDir     string
	StateDir   string
	LockPath   string
	History    string
}

func DefaultPaths

func DefaultPaths(configPath string) (Paths, error)

func Save

func Save(path string, cfg Config, force bool) (Paths, error)

type RunOptions

type RunOptions struct {
	Config Config
	Paths  Paths
	Names  []string
	Stdout io.Writer
	Stderr io.Writer
	Now    func() time.Time
}

type RunRecord

type RunRecord struct {
	ID         string   `json:"id"`
	Job        string   `json:"job"`
	Command    []string `json:"command"`
	Repo       string   `json:"repo,omitempty"`
	StartedAt  string   `json:"started_at"`
	FinishedAt string   `json:"finished_at"`
	DurationMs int64    `json:"duration_ms"`
	ExitCode   int      `json:"exit_code"`
	Status     string   `json:"status"`
	LogPath    string   `json:"log_path"`
	Error      string   `json:"error,omitempty"`
}

func ReadHistory

func ReadHistory(path string) ([]RunRecord, error)

func Run

func Run(ctx context.Context, opts RunOptions) ([]RunRecord, error)

type RunnerConfig

type RunnerConfig struct {
	Every       string `toml:"every" json:"every"`
	MaxLogBytes int64  `toml:"max_log_bytes" json:"max_log_bytes"`
}

Jump to

Keyboard shortcuts

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