schedule

package
v0.20.2 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func NewTasks added in v0.20.2

func NewTasks(
	repos *RepositoryTasks,
	repoValidator *repository.Validator,
	issuePoller *repository.IssuePoller,
	outboxRelay *repository.OutboxRelay,
	issueExplainer *global.IssueExplainer,
) []spec.Task

NewTasks is the declarative task registry. Read it as a manifest: what runs, under which partition.

Adding a per-repo task: one line in repos.Pack(...) Adding a global task: one line in global(...) Adding a partition: new XxxTasks type + new section here

func Preflight

func Preflight(s repository.TaskSpec) repoTask

Preflight marks a repository TaskSpec as a preflight task. Preflights run before all other tasks. The partition may have incomplete data (e.g. Partition.RepositoryID may be zero).

Usage in registry:

repos.Pack(
    schedule.Preflight(repoValidator.TaskSpec()),
    issuePoller.TaskSpec(),
)

Types

type Planner

type Planner struct {
	// contains filtered or unexported fields
}

Planner receives ready-to-schedule Tasks from the registry and splits them by Phase. It validates inputs (paranoid) but does not multiply or transform — that's done by providers.

func NewPlanner

func NewPlanner(tasks []spec.Task) *Planner

NewPlanner creates a Planner from Tasks provided by the registry. Panics on duplicate Task.Name — name is an operationally important identifier.

func (*Planner) Preflights

func (p *Planner) Preflights() []spec.Task

Preflights returns tasks in PhasePreflight.

func (*Planner) Workers

func (p *Planner) Workers() []spec.Task

Workers returns tasks in PhaseWork.

type RepositoryTasks added in v0.20.2

type RepositoryTasks struct {
	// contains filtered or unexported fields
}

RepositoryTasks multiplies TaskSpecs by configured repositories. Each spec × each repo = one Task. Preflights get partition without repoID, work-phase tasks get partition with lazy-resolved repoID.

func NewRepositoryTasks added in v0.20.2

func NewRepositoryTasks(cfg *config.Github, store domain.RepositoryStore) *RepositoryTasks

NewRepositoryTasks creates a RepositoryTasks.

func (*RepositoryTasks) Pack added in v0.20.2

func (rt *RepositoryTasks) Pack(entries ...any) []spec.Task

Pack multiplies specs by configured repositories and returns ready-to-schedule Tasks.

Accepts repository.TaskSpec (default PhaseWork) or Preflight()-wrapped specs. Panics on zero Interval (must use spec.OneShot) or unknown entry type.

type Scheduler

type Scheduler struct {
	// contains filtered or unexported fields
}

Scheduler orchestrates execution in two phases:

  1. Preflights — one-shot tasks, all must pass before workers start.
  2. Workers — long-running interval tasks.

Scheduler trusts Planner — it receives a flat list of Units and knows nothing about repositories, partitions, or scopes.

func NewScheduler

func NewScheduler(planner *Planner, logger *slog.Logger) *Scheduler

NewScheduler creates a Scheduler.

func (*Scheduler) Run

func (s *Scheduler) Run(ctx context.Context) error

Run executes tasks in lifecycle order: preflights first, then workers.

Jump to

Keyboard shortcuts

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