pluginhost

package
v4.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package pluginhost supervises local Control package processes. Package requests enter only after the kernel has completed admission and routing.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrHostUnavailable       = errors.New("plugin host unavailable")
	ErrHostNotFound          = errors.New("plugin host not found")
	ErrHostIncompatible      = errors.New("plugin host incompatible")
	ErrGenerationUnavailable = errors.New("plugin host generation unavailable")
)

Functions

func SetDefaultManager

func SetDefaultManager(manager Manager)

SetDefaultManager installs the process-wide supervisor used by HTTP route handlers. A nil value deliberately leaves route dispatch fail-closed.

Types

type ArtifactRef

type ArtifactRef struct {
	PackageID        string
	Version          string
	ArtifactPath     string
	ArtifactSHA256   string
	EntrypointPath   string
	EntrypointSHA256 string
	ManifestPath     string
	ManifestSHA256   string
}

ArtifactRef describes files materialized by a caller that has already bound them to a signed package release. The manager verifies every supplied digest again immediately before starting the entrypoint.

type DispatchInput

type DispatchInput struct {
	PackageID        string
	Version          string
	Generation       uint64
	RequestID        string
	IdempotencyKey   string
	RouteID          string
	Method           string
	Body             []byte
	PrincipalJSON    []byte
	Metadata         RequestMetadata
	BridgeCapability []byte
	Deadline         time.Time
}

type DispatchOutput

type DispatchOutput struct {
	StatusCode  uint32
	Body        []byte
	Headers     []Header
	OperationID string
	FailureCode string
}

type DrainResult

type DrainResult struct {
	Drained  bool
	InFlight uint64
}
type Header struct {
	Name  string
	Value string
}

type HostHealth

type HostHealth struct {
	Healthy     bool
	LeaseID     string
	DetailsJSON string
}

type ManagerConfig

type ManagerConfig struct {
	RuntimeDir     string
	StartupTimeout time.Duration
	BridgeFactory  packagebridge.SessionFactory
}

type MigrationCheckpointRecorder

type MigrationCheckpointRecorder func(context.Context, MigrationOutput) error

MigrationCheckpointRecorder must durably persist each host reply before the migration caller can observe it. A nil recorder is rejected fail-closed.

type MigrationInput

type MigrationInput struct {
	PackageID   string
	Version     string
	MigrationID string
	Checkpoint  string
	Generation  uint64
	// BridgeCapability is minted only by Supervisor and is never caller-owned.
	BridgeCapability []byte
	Deadline         time.Time
}

MigrationInput is passed through to the verified package host. Checkpoint and migration identifier values are package-owned opaque strings.

type MigrationManager

type MigrationManager interface {
	Migrate(context.Context, MigrationInput, MigrationCheckpointRecorder) (MigrationOutput, error)
}

MigrationManager is intentionally separate from Manager so existing route dispatch consumers do not gain a migration capability by accident.

type MigrationOutput

type MigrationOutput struct {
	Checkpoint       string
	ValidationDigest string
	Complete         bool
	FailureCode      string
	HealthLeaseID    string
	HealthGeneration uint64
}

MigrationOutput is the opaque reply returned by a package host. The kernel only persists and fences these values; it does not interpret their domain meaning.

type RequestMetadata

type RequestMetadata struct {
	Path                             string              `json:"path,omitempty"`
	Query                            map[string][]string `json:"query,omitempty"`
	Headers                          map[string][]string `json:"headers,omitempty"`
	PathParams                       map[string]string   `json:"path_params,omitempty"`
	ClientIP                         string              `json:"client_ip,omitempty"`
	UserAgent                        string              `json:"user_agent,omitempty"`
	NodeID                           uint                `json:"node_id,omitempty"`
	TrustedAgentWebSocketAuth        bool                `json:"trusted_agent_websocket_auth,omitempty"`
	TrustedAgentWebSocketForwardNode bool                `json:"trusted_agent_websocket_forward_node,omitempty"`
}

RequestMetadata preserves the request address independently from the package route identifier. Query values remain multi-valued because v2 clients may repeat a key.

type Supervisor

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

func NewManager

func NewManager(config ManagerConfig) (*Supervisor, error)

func (*Supervisor) Close

func (m *Supervisor) Close() error

Close retires every host and releases the pinned runtime-root descriptor.

func (*Supervisor) Dispatch

func (m *Supervisor) Dispatch(ctx context.Context, input DispatchInput) (DispatchOutput, error)

func (*Supervisor) Drain

func (m *Supervisor) Drain(ctx context.Context, packageID, version string, generation uint64, deadline time.Time) error

func (*Supervisor) Health

func (m *Supervisor) Health(ctx context.Context, packageID, version string, generation uint64) (HostHealth, error)

func (*Supervisor) Migrate

Migrate forwards one resumable migration step to the active host, persists its reply through recorder, and treats a completed response as activation only after the host health lease still matches the requested generation.

func (*Supervisor) OpenWebSocket

func (m *Supervisor) OpenWebSocket(ctx context.Context, input WebSocketInput) (*WebSocketRelay, error)

func (*Supervisor) Rollback

func (m *Supervisor) Rollback(ctx context.Context, packageID, version string, generation uint64) error

func (*Supervisor) Shutdown

func (m *Supervisor) Shutdown(ctx context.Context) error

func (*Supervisor) Start

func (m *Supervisor) Start(ctx context.Context, ref ArtifactRef, generation uint64) error

func (*Supervisor) Stop

func (m *Supervisor) Stop(ctx context.Context, packageID, version string, generation uint64) error

type WebSocketClose

type WebSocketClose struct {
	Code   uint32
	Reason string
}

type WebSocketFrame

type WebSocketFrame struct {
	Data  []byte
	Close *WebSocketClose
}

WebSocketFrame is a post-open relay frame. A nil Close represents a data frame, including an empty opaque payload.

type WebSocketInput

type WebSocketInput struct {
	PackageID        string
	Version          string
	Generation       uint64
	RouteID          string
	PrincipalJSON    []byte
	Metadata         RequestMetadata
	RequestID        string
	IdempotencyKey   string
	BridgeCapability []byte
	Deadline         time.Time
}

type WebSocketManager

type WebSocketManager interface {
	OpenWebSocket(context.Context, WebSocketInput) (*WebSocketRelay, error)
}

WebSocketManager is separate from unary route dispatch so callers must consciously opt into the bidirectional package-host transport.

type WebSocketRelay

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

WebSocketRelay owns one verified package-host stream. Callers may make one Send and one Recv call concurrently; concurrent writes are serialized.

func (*WebSocketRelay) Close

func (r *WebSocketRelay) Close(close WebSocketClose) error

func (*WebSocketRelay) Recv

func (r *WebSocketRelay) Recv() (WebSocketFrame, error)

func (*WebSocketRelay) Send

func (r *WebSocketRelay) Send(frame WebSocketFrame) error

Jump to

Keyboard shortcuts

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