Documentation
¶
Index ¶
- Variables
- func CommandsToProto(commands []Command) []*deployv1.Command
- type Command
- type ComposeInvocation
- type DockerComposeRunner
- type DockerComposeRunnerOption
- type FileStore
- type IComposeProcessExecutor
- type IExecutor
- type IStore
- type MemoryStore
- type Plan
- type Reconciler
- type Snapshot
- type StoreAdapter
Constants ¶
This section is empty.
Variables ¶
var ( // ErrStaleFence means a request came from an older leader term. ErrStaleFence = errors.New("stale leader fence") // ErrFenceConflict means two leader IDs claimed the same term. ErrFenceConflict = errors.New("conflicting leader fence") // ErrPersistence means durable state could not be read or written. ErrPersistence = errors.New("agent state persistence failed") // ErrExecution means a validated Compose plan failed to execute. ErrExecution = errors.New("compose execution failed") )
var ErrStoppedAssignmentUnsupported = errors.New("STOPPED assignments are unsupported")
ErrStoppedAssignmentUnsupported means STOPPED is outside this executor's approved Compose command surface.
Functions ¶
func CommandsToProto ¶
CommandsToProto returns isolated wire commands for a plan or snapshot.
Types ¶
type Command ¶
type Command struct {
Argv []string `json:"argv"`
}
Command is a directly executed argv vector. It is never interpreted by a shell.
type ComposeInvocation ¶
ComposeInvocation is a direct Docker Compose process invocation.
type DockerComposeRunner ¶
type DockerComposeRunner struct {
// contains filtered or unexported fields
}
DockerComposeRunner invokes the Docker CLI directly, constrained to one resolved workspace root.
func NewDockerComposeRunner ¶
func NewDockerComposeRunner( launcher proc.ILauncher, dockerBin, workspace, revisionRoot string, revisionLimits *deployv1.RevisionLimits, dryRun bool, options ...DockerComposeRunnerOption, ) (*DockerComposeRunner, error)
NewDockerComposeRunner validates the workspace and, outside dry-run mode, verifies that the Docker CLI is available. Every child process, Git and Compose alike, starts through launcher.
func NewDockerComposeRunnerWithSourceSync ¶
func NewDockerComposeRunnerWithSourceSync( launcher proc.ILauncher, dockerBin, workspace, revisionRoot string, revisionLimits *deployv1.RevisionLimits, sourceSync *deployv1.SourceSync, logger *telemetry.JSONLLogger, dryRun bool, options ...DockerComposeRunnerOption, ) (*DockerComposeRunner, error)
NewDockerComposeRunnerWithSourceSync is NewDockerComposeRunner with an optional read-only Git remote used to acquire approved commits.
func (*DockerComposeRunner) DryRun ¶
func (r *DockerComposeRunner) DryRun() bool
DryRun reports whether command execution is disabled.
func (*DockerComposeRunner) Execute ¶
func (r *DockerComposeRunner) Execute(ctx context.Context, plan Plan) error
Execute validates the internally generated plan, runs `docker compose config --quiet`, and only then runs the convergence command. Dry-run mode performs the same read-only Compose validation but never reaches the mutating command.
func (*DockerComposeRunner) Plan ¶
func (r *DockerComposeRunner) Plan(ctx context.Context, assignment *deployv1.Assignment) (Plan, error)
Plan returns the exact approved Compose command plan for one running assignment. STOPPED fails closed because its required Compose mutation is outside the executor's approved command surface.
func (*DockerComposeRunner) Workspace ¶
func (r *DockerComposeRunner) Workspace() string
Workspace returns the canonical workspace path.
type DockerComposeRunnerOption ¶
type DockerComposeRunnerOption func(dependencies *dockerComposeRunnerDependencies)
DockerComposeRunnerOption replaces an owned process-boundary dependency.
func WithComposeProcessExecutor ¶
func WithComposeProcessExecutor(executor IComposeProcessExecutor) DockerComposeRunnerOption
WithComposeProcessExecutor supplies the Docker Compose process boundary. It is primarily useful when embedding the runner or testing command policy.
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
FileStore atomically and durably stores one JSON state record. It implements both IStore (legacy) and pkgstore.IStore[Snapshot].
func NewFileStore ¶
NewFileStore constructs a file-backed state store.
type IComposeProcessExecutor ¶
type IComposeProcessExecutor interface {
Resolve(executable string) (string, error)
Run(ctx context.Context, invocation ComposeInvocation) (string, error)
}
IComposeProcessExecutor is the operating-system process boundary for Docker Compose. DockerComposeRunner owns command policy; implementations only resolve and execute the complete invocation they receive.
type IExecutor ¶
type IExecutor interface {
Plan(ctx context.Context, assignment *deployv1.Assignment) (Plan, error)
Execute(ctx context.Context, plan Plan) error
DryRun() bool
Workspace() string
}
IExecutor validates, plans, and executes a Compose reconciliation.
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is a concurrent in-memory store used by tests and embedders. It implements both IStore (legacy) and pkgstore.IStore[Snapshot].
func (*MemoryStore) Load ¶
func (s *MemoryStore) Load() (Snapshot, bool, error)
Load returns a clone of the current snapshot (legacy IStore interface).
func (*MemoryStore) Save ¶
func (s *MemoryStore) Save(snapshot Snapshot) error
Save atomically writes the snapshot (legacy IStore interface).
type Plan ¶
type Plan struct {
Commands []Command `json:"commands"`
}
Plan is a validated preflight plus convergence command.
type Reconciler ¶
type Reconciler struct {
// contains filtered or unexported fields
}
Reconciler serializes node mutations, fences leaders, and persists state.
func NewReconciler ¶
func NewReconciler(store IStore, executor IExecutor) (*Reconciler, error)
NewReconciler restores durable state before accepting requests.
func (*Reconciler) Reconcile ¶
func (r *Reconciler) Reconcile( ctx context.Context, request *deployv1.ReconcileRequest, ) (*deployv1.ReconcileResponse, error)
Reconcile validates and applies one request. The highest new fence is saved before any Docker command is allowed to run.
func (*Reconciler) Snapshot ¶
func (r *Reconciler) Snapshot() Snapshot
Snapshot returns an isolated copy of current in-memory state.
func (*Reconciler) Workspace ¶
func (r *Reconciler) Workspace() string
Workspace returns the executor's canonical workspace.
type Snapshot ¶
type Snapshot struct {
Fence *deployv1.Fence
Assignment *deployv1.Assignment
Commands []Command
UpdatedAt time.Time
}
Snapshot is the node-local durable reconciliation record.
type StoreAdapter ¶ added in v0.3.0
type StoreAdapter struct {
// contains filtered or unexported fields
}
StoreAdapter adapts the legacy IStore interface to pkgstore.IStore[Snapshot].
func NewStoreAdapter ¶ added in v0.3.0
func NewStoreAdapter(store IStore) *StoreAdapter
NewStoreAdapter wraps a legacy IStore as a pkgstore.IStore[Snapshot].