Documentation
¶
Overview ¶
Package store persists the control plane's durable state: the jobs a user submitted and the container runs launched for them. The store is the source of truth — on a controller restart the reconciler rebuilds its view from here, so a crash never loses track of a running job.
Secrets are never stored. A job's spec is persisted with its ${VAR} placeholders intact; resolved secret values live only in process memory (see the controller) and in the launched container's environment.
Index ¶
- Constants
- type DesiredState
- type Job
- type Run
- type SQLite
- func (s *SQLite) ActiveRuns() ([]*Run, error)
- func (s *SQLite) AppendTransition(t *Transition) error
- func (s *SQLite) Close() error
- func (s *SQLite) CreateJob(j *Job) error
- func (s *SQLite) CreateRun(r *Run) error
- func (s *SQLite) DeleteJob(id string) error
- func (s *SQLite) GetJob(id string) (*Job, error)
- func (s *SQLite) GetRun(id string) (*Run, error)
- func (s *SQLite) LatestRun(jobID string) (*Run, error)
- func (s *SQLite) ListJobs() ([]*Job, error)
- func (s *SQLite) ListRuns(jobID string) ([]*Run, error)
- func (s *SQLite) ListTransitions(jobID string) ([]*Transition, error)
- func (s *SQLite) SetDesired(jobID string, d DesiredState) error
- func (s *SQLite) UpdateRun(r *Run) error
- type Store
- type Transition
Constants ¶
const ( KindYAML = "yaml" KindSDK = "sdk" )
KindSDK / KindYAML are the Job.Kind values.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DesiredState ¶
type DesiredState string
DesiredState is the operator's intent for a job, independent of what any individual container is doing right now. The reconciler drives the actual runs toward this.
const ( // DesiredRunning: the job should have a live container. DesiredRunning DesiredState = "running" // DesiredStopped: the job should be stopped and stay stopped. DesiredStopped DesiredState = "stopped" )
type Job ¶
type Job struct {
ID string `json:"id"`
Name string `json:"name"`
// Kind is "yaml" (a declarative workflow) or "sdk" (a prebuilt Go
// pipeline image). Empty is treated as "yaml".
Kind string `json:"kind,omitempty"`
Spec string `json:"spec"` // workflow doc (yaml) or manifest (sdk), secrets unresolved
// Image is the container image to run. Empty for yaml jobs (the
// controller's generic runner image is used); set for sdk jobs.
Image string `json:"image,omitempty"`
Delivery compiler.DeliveryGuarantee `json:"delivery"`
Graph compiler.PipelineGraph `json:"graph"`
Desired DesiredState `json:"desiredState"`
Created time.Time `json:"createdAt"`
Updated time.Time `json:"updatedAt"`
}
Job is a submitted workflow and the operator's intent for it.
type Run ¶
type Run struct {
ID string `json:"id"`
JobID string `json:"jobId"`
ContainerID string `json:"containerId,omitempty"`
HostPort int `json:"hostPort,omitempty"` // mapped control-surface port
Phase string `json:"phase"`
Attempt int `json:"attempt"`
Error string `json:"error,omitempty"`
Started time.Time `json:"startedAt"`
Stopped *time.Time `json:"stoppedAt,omitempty"`
}
Run is one container launched for a job. A job accumulates runs across restarts; at most one is non-terminal at a time.
type SQLite ¶
type SQLite struct {
// contains filtered or unexported fields
}
SQLite is a Store backed by a single SQLite database file (or ":memory:"). modernc's driver is pure Go, so the controller image needs no CGO.
func OpenSQLite ¶
OpenSQLite opens (creating if needed) the database at path and applies the schema. Use ":memory:" for tests.
func (*SQLite) ActiveRuns ¶
func (*SQLite) AppendTransition ¶
func (s *SQLite) AppendTransition(t *Transition) error
func (*SQLite) ListTransitions ¶
func (s *SQLite) ListTransitions(jobID string) ([]*Transition, error)
func (*SQLite) SetDesired ¶
func (s *SQLite) SetDesired(jobID string, d DesiredState) error
type Store ¶
type Store interface {
CreateJob(j *Job) error
GetJob(id string) (*Job, error)
ListJobs() ([]*Job, error)
SetDesired(jobID string, d DesiredState) error
DeleteJob(id string) error
CreateRun(r *Run) error
UpdateRun(r *Run) error
GetRun(id string) (*Run, error)
// LatestRun returns the most recent run for a job, or (nil, nil) if
// the job has never been launched.
LatestRun(jobID string) (*Run, error)
ListRuns(jobID string) ([]*Run, error)
// ActiveRuns returns every non-terminal run across all jobs — the set
// the reconciler must watch.
ActiveRuns() ([]*Run, error)
AppendTransition(t *Transition) error
ListTransitions(jobID string) ([]*Transition, error)
Close() error
}
Store is the persistence contract. Implementations must be safe for concurrent use (the API server and reconciler share one).