lifecycle

package
v0.1.0-proto2a Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateInitializing = "initializing"
	StateInitialized  = "initialized"
	StateStarting     = "starting"
	StateRunning      = "running"
	StateStopping     = "stopping"
	StateStopped      = "stopped"
	StateReloading    = "reloading"
	StateRestarting   = "restarting"
	StateError        = "error"
)

Variables

View Source
var DepCtxKey = depCtxKey{}

DepCtxKey is used to store the call stack for cycle detection

Functions

This section is empty.

Types

type Action

type Action string
const (
	ActionInitialize Action = "initialize"
	ActionStart      Action = "start"
	ActionStop       Action = "stop"
	ActionRestart    Action = "restart"
	ActionReload     Action = "reload"
)

type Agent

type Agent interface {
	Initialize() error
	Start() error
	Stop() error
	Restart() error
	Reload() error
	Describe() *meta.AgentInfo
	ID() string
	Type() string
	Scope() string
}

type Checkpointer

type Checkpointer interface {
	// Checkpoint writes a checkpoint of the runner's process into dir,
	// which must already exist.
	//
	// On success the process is STOPPED. That is deliberate: the image
	// is the rollback artifact for a migration, and a source that keeps
	// executing past the point its image captured has already diverged
	// from it.
	Checkpoint(ctx context.Context, dir string) error

	// Restore recreates the process from the checkpoint in dir and
	// adopts it, so the runner's Pid reports the restored process and
	// Stop can terminate it.
	//
	// The restored process is not a child of this program - CRIU spawns
	// it - so it is tracked by pid and reparents to the supervisor's
	// subreaper, which is how its eventual exit is observed.
	Restore(ctx context.Context, dir string) error
}

Checkpointer is an optional capability for runners whose process can be checkpointed and restored with CRIU (GOBLIN-DIV-018). Runners that cannot be dumped - anything running in-process rather than as a separate program - simply do not implement it, and an orchestrator asserts the capability once at admission rather than discovering at migration time that a workload was never movable.

Both methods take a context on the same terms as Start: it bounds the call, not the lifetime of the process the call produces.

type Controller

type Controller struct {
	GraceStop time.Duration
	WaitStart time.Duration
	WaitStop  time.Duration
	// contains filtered or unexported fields
}

func NewController

func NewController(id, host string, r Runner, bus *TypedBus, deps DependencyResolver) *Controller

func (*Controller) Apply

func (c *Controller) Apply(a Action) error

func (*Controller) ApplyWithContext

func (c *Controller) ApplyWithContext(ctx context.Context, a Action) error

func (*Controller) State

func (c *Controller) State() string

type DependencyResolver

type DependencyResolver interface {
	DepsOf(id string) []string
	IsRunning(id string) bool
	EnsureStarted(ctx context.Context, id string) error
}

type LifecycleStateMachine

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

func NewLifecycleStateMachine

func NewLifecycleStateMachine(agentID, hostname string, bus *eventbus.EventBus[*anypb.Any]) *LifecycleStateMachine

func (*LifecycleStateMachine) CurrentProtoState

func (lsm *LifecycleStateMachine) CurrentProtoState() protopkg.AgentState

func (*LifecycleStateMachine) GetState

func (lsm *LifecycleStateMachine) GetState() string

func (*LifecycleStateMachine) TransitionTo

func (lsm *LifecycleStateMachine) TransitionTo(newState string) error

type RunIDSetter

type RunIDSetter interface {
	SetRunID(string)
}

Optional capability for runners to support per-start correlation.

type Runner

type Runner interface {
	// Start spawns the runner's process. The context bounds the start
	// operation only - it is cancelled as soon as Start returns, so an
	// implementation must NOT tie the spawned process's lifetime to it.
	// exec.CommandContext here means the process is SIGKILLed the moment
	// the start call completes (GAPI-DIV-028); use exec.Command and let
	// Stop own the process.
	Start(ctx context.Context) error
	Stop(ctx context.Context) error
	Reload(ctx context.Context) error
	Reset()
}

type TypedBus

type TypedBus = eventbus.EventBus[*anypb.Any]

Jump to

Keyboard shortcuts

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