Documentation
¶
Overview ¶
Package control is the Mailer job control plane: it accepts workflow submissions, launches one container per job through a ContainerBackend, persists everything to a Store, and reconciles the running containers toward each job's desired state. It is the JobManager equivalent for the single-container-per-job model (see the job-orchestration plan, P3).
Index ¶
- type Controller
- func (c *Controller) Cancel(ctx context.Context, jobID string) error
- func (c *Controller) ControlAddress(ctx context.Context, jobID string) (string, error)
- func (c *Controller) GetJob(id string) (*store.Job, error)
- func (c *Controller) LatestRun(jobID string) (*store.Run, error)
- func (c *Controller) ListJobs() ([]*store.Job, error)
- func (c *Controller) Logs(ctx context.Context, jobID string, tail int) (string, error)
- func (c *Controller) Reconcile(ctx context.Context) error
- func (c *Controller) Restart(ctx context.Context, jobID string) (*store.Job, error)
- func (c *Controller) RestartFromSavepoint(ctx context.Context, jobID, label string) (*store.Job, error)
- func (c *Controller) RunReconciler(ctx context.Context, interval time.Duration)
- func (c *Controller) Savepoint(ctx context.Context, jobID, label string) error
- func (c *Controller) Submit(ctx context.Context, doc []byte, env map[string]string) (*store.Job, error)
- func (c *Controller) Transitions(jobID string) ([]*store.Transition, error)
- func (c *Controller) Validate(doc []byte, env map[string]string) (string, compiler.DeliveryGuarantee, compiler.PipelineGraph, error)
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller ties the store, backend, and lifecycle rules together.
func (*Controller) Cancel ¶
func (c *Controller) Cancel(ctx context.Context, jobID string) error
Cancel sets the job's desired state to stopped and stops its live container gracefully. The container is kept (not removed) so logs stay available; a later Restart or GC removes it.
func (*Controller) ControlAddress ¶
ControlAddress returns the host:port of a job's live control surface, or "" if the job has no reachable running container.
func (*Controller) GetJob ¶
func (c *Controller) GetJob(id string) (*store.Job, error)
GetJob returns one job.
func (*Controller) LatestRun ¶
func (c *Controller) LatestRun(jobID string) (*store.Run, error)
LatestRun returns the most recent run for a job (nil if never launched).
func (*Controller) ListJobs ¶
func (c *Controller) ListJobs() ([]*store.Job, error)
ListJobs returns all jobs, newest first.
func (*Controller) Reconcile ¶
func (c *Controller) Reconcile(ctx context.Context) error
Reconcile drives every active run toward its job's desired state once. It is the single place that observes real container status and updates the store — so after a controller restart, calling Reconcile re-attaches to the containers the store still knows about (the store is the source of truth). Safe to call repeatedly.
func (*Controller) Restart ¶
Restart stops any live run and launches a fresh one, resetting the desired state to running and the attempt counter.
func (*Controller) RestartFromSavepoint ¶
func (c *Controller) RestartFromSavepoint(ctx context.Context, jobID, label string) (*store.Job, error)
RestartFromSavepoint restarts the job, seeding the new run's state from the named savepoint instead of the last automatic checkpoint.
func (*Controller) RunReconciler ¶
func (c *Controller) RunReconciler(ctx context.Context, interval time.Duration)
RunReconciler runs Reconcile on a ticker until ctx is cancelled. Call it in a goroutine from the controller process.
func (*Controller) Savepoint ¶
func (c *Controller) Savepoint(ctx context.Context, jobID, label string) error
Savepoint triggers a stop-with-savepoint on the job's live container: the job drains, writes its final checkpoint, and the runner promotes it to a named savepoint. The job's desired state becomes stopped.
func (*Controller) Submit ¶
func (c *Controller) Submit(ctx context.Context, doc []byte, env map[string]string) (*store.Job, error)
Submit validates a workflow document, records the job (desired: running), and launches its first container. The env carries any secrets; it is used for validation and passed to the container but never persisted. A validation failure rejects the job before any container starts.
func (*Controller) Transitions ¶
func (c *Controller) Transitions(jobID string) ([]*store.Transition, error)
Transitions returns a job's lifecycle audit log.
func (*Controller) Validate ¶
func (c *Controller) Validate(doc []byte, env map[string]string) (string, compiler.DeliveryGuarantee, compiler.PipelineGraph, error)
Validate compiles a workflow without launching it — the dry-run preview behind the submit form. Returns the name, delivery guarantee, and graph a submit would produce, or an error if the workflow is invalid.
type Options ¶
type Options struct {
Store store.Store
Backend backend.ContainerBackend
Image string // runner image tag
ControlPort int // container control port (default 8080)
Restart lifecycle.RestartPolicy // default: lifecycle.DefaultRestartPolicy()
StopTimeout time.Duration // graceful stop wait (default 30s)
NewID func() string // override for deterministic tests
Logf func(string, ...any) // optional logger
}
Options configures a Controller.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package api exposes the Controller over HTTP: submit, list, inspect, cancel, restart, and log/metric access for jobs.
|
Package api exposes the Controller over HTTP: submit, list, inspect, cancel, restart, and log/metric access for jobs. |
|
Package backend abstracts where a job's container actually runs.
|
Package backend abstracts where a job's container actually runs. |
|
cmd
|
|
|
mailer
command
Command mailer is the control-plane CLI.
|
Command mailer is the control-plane CLI. |
|
Package lifecycle defines the controller's view of a job's phases and the rules that move a job between them.
|
Package lifecycle defines the controller's view of a job's phases and the rules that move a job between them. |
|
Package store persists the control plane's durable state: the jobs a user submitted and the container runs launched for them.
|
Package store persists the control plane's durable state: the jobs a user submitted and the container runs launched for them. |
|
Package ui embeds and serves the control-plane dashboard — a single self-contained HTML page (inline CSS/JS, no external assets) so the controller binary needs no build step or static file deployment.
|
Package ui embeds and serves the control-plane dashboard — a single self-contained HTML page (inline CSS/JS, no external assets) so the controller binary needs no build step or static file deployment. |