Documentation
¶
Overview ¶
Package supervisor runs generic local component processes and projects their observed lifecycle into a graph. It does not decide why a process is trusted or whether a consumer is authorized to start it.
Index ¶
- Constants
- Variables
- type Artifact
- type Connection
- type Endpoint
- type Instance
- type Options
- type Orphan
- type OrphanPolicy
- type ProcessPolicy
- type RestartPolicy
- type SecretReference
- type Spec
- type State
- type Supervisor
- func (s *Supervisor) Close(ctx context.Context) error
- func (s *Supervisor) Health(ctx context.Context, id string) (bool, error)
- func (s *Supervisor) Instance(id string) (Instance, error)
- func (s *Supervisor) Instances() []Instance
- func (s *Supervisor) Logs(id string) (string, error)
- func (s *Supervisor) Orphans() []Orphan
- func (s *Supervisor) ResolveOrphan(ctx context.Context, id string) error
- func (s *Supervisor) Start(ctx context.Context, spec Spec) (Instance, error)
- func (s *Supervisor) Stop(ctx context.Context, id string) error
Constants ¶
const RuntimeNamespace = "ext.runtime"
Variables ¶
var ErrRuntimeLeased = errors.New("runtime still has a live supervisor lease")
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Instance ¶
type Instance struct {
ID string `json:"id"`
Artifact Artifact `json:"artifact"`
State State `json:"state"`
PID int `json:"pid,omitempty"`
ProcessIdentity string `json:"process_identity,omitempty"`
StartedAt time.Time `json:"started_at,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
ExitCode *int `json:"exit_code,omitempty"`
CrashCount int `json:"crash_count"`
Health string `json:"health,omitempty"`
LastError string `json:"last_error,omitempty"`
Endpoints []Endpoint `json:"endpoints,omitempty"`
Connections []Connection `json:"connections,omitempty"`
Dependencies []string `json:"dependencies,omitempty"`
}
type Options ¶
type Options struct {
Graph store.Store
SecretResolver func(context.Context, SecretReference) (string, error)
LogLimit int
RuntimeID string
RequireChecksum bool
OrphanPolicy OrphanPolicy
LeaseDuration time.Duration
RetainTerminal int
// ProcessPolicyFactory installs optional platform resource or sandbox
// controls for each launch attempt. CTX still controls the process tree.
ProcessPolicyFactory func(Spec) (ProcessPolicy, error)
}
type OrphanPolicy ¶
type OrphanPolicy string
const ( // OrphanMark records an expired process lease and blocks new starts until // the caller explicitly resolves that process. OrphanMark OrphanPolicy = "mark" // OrphanTerminate terminates identity-matched process trees on recovery. OrphanTerminate OrphanPolicy = "terminate" )
type ProcessPolicy ¶
ProcessPolicy is an optional platform control supplied by an embedding service. Configure runs before checksum verification and secret resolution; Attach runs immediately after the child starts.
type RestartPolicy ¶
type SecretReference ¶
type Spec ¶
type Spec struct {
Artifact Artifact
Command string
Args []string
Dir string
Environment map[string]string
SecretReferences map[string]SecretReference
Endpoints []Endpoint
Connections []Connection
Dependencies []string
Restart RestartPolicy
HealthCheck func(context.Context) error
// EndpointReady checks that the declared endpoints can accept connections.
// ProtocolHandshake verifies the consumer's protocol after endpoint readiness.
// Neither hook receives resolved secret values.
EndpointReady func(context.Context, Instance) error
ProtocolHandshake func(context.Context, Instance) error
ReadinessTimeout time.Duration
}
type Supervisor ¶
type Supervisor struct {
// contains filtered or unexported fields
}
func New ¶
func New(opts Options) (*Supervisor, error)
func (*Supervisor) Instances ¶
func (s *Supervisor) Instances() []Instance
func (*Supervisor) Orphans ¶
func (s *Supervisor) Orphans() []Orphan
Orphans returns processes left by an expired supervisor lease. While any live orphan remains unresolved, Start refuses to create another process.
func (*Supervisor) ResolveOrphan ¶
func (s *Supervisor) ResolveOrphan(ctx context.Context, id string) error
ResolveOrphan terminates an identity-matched orphan process tree and clears its durable orphan state. It never targets a reused PID.