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
- Variables
- func SetDefaultManager(manager Manager)
- type ArtifactRef
- type DispatchInput
- type DispatchOutput
- type DrainResult
- type Header
- type HostHealth
- type HostStats
- type HostStatsProvider
- type Manager
- type ManagerConfig
- type MigrationCheckpointRecorder
- type MigrationInput
- type MigrationManager
- type MigrationOutput
- type MigrationStep
- type RemoteConfig
- type RemoteInstances
- type RequestMetadata
- type Supervisor
- func (m *Supervisor) BindInstance(context.Context, packagebridge.InstanceBinding) (*packagebridge.GenerationSession, error)
- func (*Supervisor) Close() error
- func (*Supervisor) Dispatch(context.Context, DispatchInput) (DispatchOutput, error)
- func (*Supervisor) Drain(context.Context, string, string, uint64, time.Time) error
- func (m *Supervisor) EnableRemote(RemoteConfig) error
- func (*Supervisor) Health(context.Context, string, string, uint64) (HostHealth, error)
- func (*Supervisor) Migrate(context.Context, MigrationInput, MigrationCheckpointRecorder) (MigrationOutput, error)
- func (*Supervisor) OpenWebSocket(context.Context, WebSocketInput) (*WebSocketRelay, error)
- func (m *Supervisor) PackageConn(string) (grpc.ClientConnInterface, error)
- func (*Supervisor) PollHealth(context.Context, time.Duration)
- func (*Supervisor) Rollback(context.Context, string, string, uint64) error
- func (*Supervisor) Shutdown(context.Context) error
- func (*Supervisor) Start(context.Context, ArtifactRef, uint64) error
- func (*Supervisor) Stats() []HostStats
- func (*Supervisor) Stop(context.Context, string, string, uint64) error
- type WebSocketClose
- type WebSocketFrame
- type WebSocketInput
- type WebSocketManager
- type WebSocketRelay
Constants ¶
const ( HostStateRunning = "running" HostStateRestarting = "restarting" HostStateFailed = "failed" HostStateExited = "exited" HostStateStopped = "stopped" )
Host supervision states reported by HostStats.State.
Variables ¶
var ( ErrHostNotFound = errors.New("plugin host not found") ErrHostIncompatible = errors.New("plugin host incompatible") ErrPackageFailed = errors.New("plugin package failed") // the request with its legacy handler. ErrLegacyUnavailable = errors.New("plugin route has no kernel legacy handler") )
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 DrainResult ¶
type HostHealth ¶
type HostStatsProvider ¶ added in v4.1.0
type HostStatsProvider interface {
Stats() []HostStats
}
type Manager ¶
type Manager interface {
Start(context.Context, ArtifactRef, uint64) error
Dispatch(context.Context, DispatchInput) (DispatchOutput, error)
Health(context.Context, string, string, uint64) (HostHealth, error)
Drain(context.Context, string, string, uint64, time.Time) error
Stop(context.Context, string, string, uint64) error
Rollback(context.Context, string, string, uint64) error
}
func DefaultManager ¶
func DefaultManager() Manager
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 MigrationManager ¶
type MigrationManager interface {
Migrate(context.Context, MigrationInput, MigrationCheckpointRecorder) (MigrationOutput, error)
}
type MigrationOutput ¶
type MigrationStep ¶ added in v4.1.0
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
func (m *Supervisor) BindInstance(context.Context, packagebridge.InstanceBinding) (*packagebridge.GenerationSession, error)
BindInstance admits no remote instance without Unix package hosts.
func (*Supervisor) Close ¶
func (*Supervisor) Close() error
func (*Supervisor) Dispatch ¶
func (*Supervisor) Dispatch(context.Context, DispatchInput) (DispatchOutput, error)
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) Health(context.Context, string, string, uint64) (HostHealth, error)
func (*Supervisor) Migrate ¶
func (*Supervisor) Migrate(context.Context, MigrationInput, MigrationCheckpointRecorder) (MigrationOutput, error)
func (*Supervisor) OpenWebSocket ¶
func (*Supervisor) OpenWebSocket(context.Context, WebSocketInput) (*WebSocketRelay, error)
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) Start ¶
func (*Supervisor) Start(context.Context, ArtifactRef, uint64) error
func (*Supervisor) Stats ¶ added in v4.1.0
func (*Supervisor) Stats() []HostStats
type WebSocketClose ¶
type WebSocketFrame ¶
type WebSocketFrame struct {
Data []byte
Close *WebSocketClose
}
type WebSocketInput ¶
type WebSocketManager ¶
type WebSocketManager interface {
OpenWebSocket(context.Context, WebSocketInput) (*WebSocketRelay, error)
}
type WebSocketRelay ¶
type WebSocketRelay struct{}
func (*WebSocketRelay) Close ¶
func (*WebSocketRelay) Close(WebSocketClose) error
func (*WebSocketRelay) Recv ¶
func (*WebSocketRelay) Recv() (WebSocketFrame, error)
func (*WebSocketRelay) Send ¶
func (*WebSocketRelay) Send(WebSocketFrame) error