jobspec

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 10 Imported by: 1 module, 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 jobspec reads what a job's WORKER.md says about when and where it runs: its schedule (plain text or cron, in a time zone), where it runs (here, on the computer, or on the organization's service), what to do about missed times and its time limit. Blitz's workers and the organization's service read jobs with it alike.

Index

Constants

View Source
const (
	// Here is on the person's computer, while Blitz's service runs.
	Here = "here"
	// Service is on the organization's service, at every time.
	Service = "service"
)

Where a job runs (spec_053_enterprise EN-40).

View Source
const (
	// MergeMain adds them to the workspace's main too when they merge
	// cleanly: the default.
	MergeMain = "main"
	// MergeNever keeps them on the run's branch, for someone to add.
	MergeNever = "never"
)

Where a run on the service leaves its changes (blitz-enterprise spec_009_jobs JB-10): each goes to its own branch first.

View Source
const FileName = "WORKER.md"

FileName is the file that defines a job, in its own directory.

Variables

This section is empty.

Functions

func MergeOf

func MergeOf(s string) (string, error)

MergeOf is what merge says: MergeMain when unset.

func RunsOn

func RunsOn(s string) (string, error)

RunsOn is where runs_on says a job runs: Here when unset.

func Split

func Split(data []byte) (fm, body []byte, err error)

Split is a WORKER.md's frontmatter (between lines of ---) and its body. The front matter ends at the next line that is only --- (trailing spaces and a CR allowed), never at a --- inside a value, as SKILL.md's does (the engine's frontmatter.Split, which this package can't import).

Types

type Schedule

type Schedule struct {
	// Text is the schedule as written.
	Text string
	// Cron is how it was understood: a five-field cron expression, or a
	// descriptor ("@hourly", "@every 90m").
	Cron     string
	Location *time.Location
	// contains filtered or unexported fields
}

Schedule is when a worker runs.

func ParseSchedule

func ParseSchedule(text, tz string) (Schedule, error)

ParseSchedule understands a cron expression, a descriptor, or plain text ("Every two hours", "Daily at 6 AM", "Weekdays at 9:30", "Every Monday at 8 PM") in the time zone named tz ("" for the machine's). Plain text is translated by fixed rules, never guessed: anything else is an error.

func (Schedule) Next

func (s Schedule) Next(t time.Time) time.Time

Next is the first run after t.

type Spec

type Spec struct {
	Description string
	// Schedule is as written; empty for a job run only on request.
	Schedule, Timezone string
	// RunsOn is Here or Service.
	RunsOn string
	// CatchUp is "none" or "once".
	CatchUp string
	// Timeout is a run's time limit (0: the runner's default).
	Timeout time.Duration
	// Merge is where a run on the service leaves its changes: MergeMain or
	// MergeNever.
	Merge string
}

Spec is when and where a job runs.

func Parse

func Parse(data []byte) (Spec, error)

Parse reads a WORKER.md's frontmatter, ignoring what it doesn't need, and checks what it reads: a schedule it can't understand, an unknown place to run, catch-up or timeout is an error.

Jump to

Keyboard shortcuts

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