pluginhost

package
v4.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Overview

Package pluginhost exposes fail-closed stubs on platforms that cannot provide the Unix socket and descriptor isolation required by package hosts.

Index

Constants

View Source
const (
	HostStateRunning    = "running"
	HostStateRestarting = "restarting"
	HostStateFailed     = "failed"
	HostStateExited     = "exited"
	HostStateStopped    = "stopped"
)

Host supervision states reported by HostStats.State.

Variables

View Source
var (
	ErrHostUnavailable       = errors.New("plugin host unavailable")
	ErrHostNotFound          = errors.New("plugin host not found")
	ErrHostIncompatible      = errors.New("plugin host incompatible")
	ErrPackageFailed         = errors.New("plugin package failed")
	ErrGenerationUnavailable = errors.New("plugin host generation unavailable")
	// ErrLegacyUnavailable matches the Unix build: the kernel cannot serve
	// the request with its legacy handler.
	ErrLegacyUnavailable = errors.New("plugin route has no kernel legacy handler")
)
View Source
var ErrResponseTooLarge = errors.New("plugin response exceeds its limit")

ErrResponseTooLarge reports a package response above the configured response limit (codes.ResourceExhausted from the host, or a host message the kernel client refused to receive). It is always wrapped together with ErrHostUnavailable so existing callers keep failing closed.

Functions

func SetDefaultManager

func SetDefaultManager(manager Manager)

Types

type ArtifactRef

type ArtifactRef struct {
	PackageID        string
	Version          string
	ArtifactPath     string
	ArtifactSHA256   string
	EntrypointPath   string
	EntrypointSHA256 string
	ManifestPath     string
	ManifestSHA256   string
	// MigrationIndexSHA256 and Migrations describe the verified migration
	// index of the release; Migrations is empty when it declares no steps.
	MigrationIndexSHA256 string
	Migrations           []MigrationStep
	// Storage is set when the signed manifest declares kernel.storage.v1.
	// Only such releases run their migration index through the kernel's
	// migration ledger when the host starts.
	Storage bool
}

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
	// BridgeBody is the body the bridge capability retains for the
	// kernel's legacy handler when the host reads another one: the request
	// as the client sent it, while Body has its node secrets sealed. Nil
	// retains Body.
	BridgeBody []byte
	// SealedRequest names the request's sealed secrets; the capability
	// carries it so that KernelNodeOps resolves them for this request only.
	SealedRequest string
}

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 HostStats added in v4.1.0

type HostStats struct {
	PackageID       string
	Version         string
	Generation      uint64
	State           string
	Starts          uint64
	UnexpectedExits uint64
	Restarts        uint64
	Failures        uint64

	HealthDetailsJSON string
	HealthCheckedAt   time.Time
}

type HostStatsProvider added in v4.1.0

type HostStatsProvider interface {
	Stats() []HostStats
}

type ManagerConfig

type ManagerConfig struct {
	RuntimeDir     string
	StartupTimeout time.Duration
	BridgeFactory  packagebridge.SessionFactory
	// MaxResponseBytes is plugins.control_host_max_response_bytes. It is
	// passed to hosts as ANIX_CONTROL_HOST_MAX_RESPONSE_BYTES and bounds the
	// kernel client's receive size. Zero selects the 1 MiB default.
	MaxResponseBytes int64
	// PackageEnvironment adds "NAME=value" entries to one package's local
	// host environment.
	PackageEnvironment map[string][]string
}

type MigrationCheckpointRecorder

type MigrationCheckpointRecorder func(context.Context, MigrationOutput) error

type MigrationInput

type MigrationInput struct {
	PackageID        string
	Version          string
	MigrationID      string
	Checkpoint       string
	Generation       uint64
	BridgeCapability []byte
	Deadline         time.Time
}

type MigrationManager

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

type MigrationOutput

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

type MigrationStep added in v4.1.0

type MigrationStep struct {
	ID     string
	Path   string
	SHA256 string
}

MigrationStep is one verified step of a package migration index.

type RemoteConfig added in v4.1.0

type RemoteConfig struct {
	Instances   RemoteInstances
	TLS         moduletls.Source
	Cluster     string
	IsRemote    func(ctx context.Context, packageID string) (bool, error)
	BindTimeout time.Duration
}

RemoteConfig enables the remote runtime of a Supervisor.

type RemoteInstances added in v4.1.0

type RemoteInstances interface {
	Instances(packageID string, generation uint64) []packagebridge.BoundInstance
}

RemoteInstances lists the module instances bound to a generation.

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"`
	// Host and TLS describe the original request address as
	// internal/requestorigin resolves it: the Host header and whether the
	// connection was TLS, or X-Forwarded-Host/Proto when the peer is a
	// trusted reverse proxy (server.trusted_proxies). Host is kept only when
	// it is a plain host[:port] (validPackageRequestHost). They are never request metadata JSON
	// keys, because hosts built with the v4.0.0 SDK reject unknown keys. The
	// kernel's bridge snapshot carries them as "host" and "tls", and package
	// hosts receive them as the DispatchRequest and WebSocketOpen fields
	// request_host and request_scheme, which older hosts skip.
	Host string `json:"-"`
	TLS  bool   `json:"-"`
}

type Supervisor

type Supervisor struct{}

func NewManager

func NewManager(ManagerConfig) (*Supervisor, error)

func (*Supervisor) BindInstance added in v4.1.0

BindInstance admits no remote instance without Unix package hosts.

func (*Supervisor) Close

func (*Supervisor) Close() error

func (*Supervisor) Dispatch

func (*Supervisor) Drain

func (*Supervisor) EnableRemote added in v4.1.0

func (m *Supervisor) EnableRemote(RemoteConfig) error

EnableRemote is unavailable without Unix package hosts.

func (*Supervisor) Health

func (*Supervisor) OpenWebSocket

func (*Supervisor) PackageConn added in v4.1.0

func (m *Supervisor) PackageConn(string) (grpc.ClientConnInterface, error)

PackageConn has no host to reach without Unix package hosts.

func (*Supervisor) PollHealth added in v4.1.0

func (*Supervisor) PollHealth(context.Context, time.Duration)

func (*Supervisor) Rollback

func (*Supervisor) Shutdown

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

func (*Supervisor) Start

func (*Supervisor) Stats added in v4.1.0

func (*Supervisor) Stats() []HostStats

func (*Supervisor) Stop

type WebSocketClose

type WebSocketClose struct {
	Code   uint32
	Reason string
}

type WebSocketFrame

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

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)
}

type WebSocketRelay

type WebSocketRelay struct{}

func (*WebSocketRelay) Close

func (*WebSocketRelay) Recv

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

func (*WebSocketRelay) Send

Jump to

Keyboard shortcuts

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