host

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package host opens an installed package as a running plugin and calls it by dotted method name. It composes store (verified content), process (launch) and the plugin session (handshake, admission); it chooses no install location and grants no authority beyond the descriptor the caller reviewed.

Index

Constants

View Source
const DefaultTimeout = 10 * time.Minute

DefaultTimeout bounds handshake and calls without an earlier caller deadline.

View Source
const DrainTimeout = 5 * time.Second

DrainTimeout is how long Close waits for admitted calls before aborting.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Verify runs after package verification and before process launch. Use it
	// to recheck caller-owned trust or a separately installed runtime package.
	Verify func(context.Context) error
	// Launch overrides how the package starts, for example to run source files
	// under a runtime the consumer manages (Path is that runtime, Args begin
	// with the script). Dir defaults to the package directory, not the caller's
	// working directory: a plugin that runs commands for the user needs Dir set
	// explicitly. When nil, the
	// package's first entrypoint artifact is started with no arguments.
	Launch *process.Command
	// Authorize runs before every call. When nil, any operation the reviewed
	// descriptor declares is allowed.
	Authorize func(context.Context, plugin.Request) error
	// Timeout bounds the handshake and calls without an earlier caller
	// deadline. Zero uses DefaultTimeout.
	Timeout time.Duration
	// Env adds KEY=value entries to the child's environment, which is otherwise
	// scrubbed (PATH only, plus SystemRoot on Windows). It applies to the default
	// launch and is added to Launch.Env when Launch is set. A name may appear only
	// once across both.
	Env []string
	// Reverse offers services to the plugin: calls from the plugin to this
	// host, limited to the operations its descriptor declares in Reverse. When
	// nil, every reverse call is denied.
	Reverse *ReverseOptions
}

Options supplies the admission policy and launch choice.

type Process

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

Process is one plugin process behind a plugin session.

func Open

func Open(ctx context.Context, installed store.Installed, options Options) (*Process, error)

Open re-verifies the installed package, starts it and completes the handshake. Verification binds the launch to the installed content; it is not publisher trust, which stays with the consumer.

ctx bounds the start and the handshake only. It does not bound the process: cancelling it after Open returns does not stop the plugin or its calls. Close ends the process, and each Call takes its own context.

func OpenRuntime added in v0.2.0

func OpenRuntime(ctx context.Context, installed store.Installed, runtime RuntimeOptions) (*Process, error)

OpenRuntime re-verifies both installed packages and the reviewed runtime digest immediately before starting a source guest. The caller still owns plugin-package trust, runtime trust, and operation authorization.

func (*Process) Call

func (p *Process) Call(ctx context.Context, method string, params any, result any) error

Call invokes "<contract>.<operation>" (see plugin.Descriptor.ResolveMethod). params is JSON-encoded, with nil meaning JSON null. A non-nil result receives the decoded payload; a null payload leaves it untouched.

func (*Process) CallProgress

func (p *Process) CallProgress(ctx context.Context, method string, params any, result any, onProgress func(plugin.Progress), options ...plugin.CallOptions) error

CallProgress is Call for an operation that declares progress: onProgress receives its progress and log events while the call runs. It must not block. Events beyond the rate limit are dropped and counted in the next event's Dropped field. The result is unchanged.

func (*Process) Close

func (p *Process) Close() error

Close drains admitted calls for DrainTimeout, then aborts the child.

func (*Process) Descriptor

func (p *Process) Descriptor() plugin.Descriptor

Descriptor is a copy of the session's reviewed descriptor.

func (*Process) Done

func (p *Process) Done() <-chan struct{}

Done is closed once the plugin session has ended, whether by Close, an abort or a failed call. Anything whose lifetime is tied to the plugin, such as an endpoint grant (endpoint.Admit takes it), ends with it.

func (*Process) Stderr

func (p *Process) Stderr() string

Stderr returns bounded, untrusted diagnostic output from the child.

type ReverseOptions

type ReverseOptions = plugin.ReverseOptions

ReverseOptions configures the services a host offers to its plugin; it is plugin.ReverseOptions, so a host need not import the root package for it.

type RuntimeOptions added in v0.2.0

type RuntimeOptions struct {
	Runtime         store.Installed
	ReviewedDigest  string
	RuntimeArtifact string
	Executable      string
	ScriptArtifact  string
	Arguments       []string
	Options         Options
}

RuntimeOptions binds a source plugin to a separately installed, reviewed runtime package. The runtime executable can be a file artifact or a file inside a verified tree artifact. ScriptArtifact belongs to the plugin package, so neither path is selected from ambient PATH.

Directories

Path Synopsis
Package adapter is the host side of the adapter system: manifests, the installed-adapter store, package lifecycle, trust checks and executable invocation.
Package adapter is the host side of the adapter system: manifests, the installed-adapter store, package lifecycle, trust checks and executable invocation.
adaptercmd
Package adaptercmd provides the shared ext adapter management command.
Package adaptercmd provides the shared ext adapter management command.
Package home resolves Ext's shared per-user package roots.
Package home resolves Ext's shared per-user package roots.
Package interop plans explicit transport connections between CTX peers.
Package interop plans explicit transport connections between CTX peers.
Package nativego loads trusted Go shared objects built with -buildmode=plugin.
Package nativego loads trusted Go shared objects built with -buildmode=plugin.
Package process starts a plugin as a child process and binds it to the JSON-line protocol over its stdin and stdout.
Package process starts a plugin as a child process and binds it to the JSON-line protocol over its stdin and stdout.
Package store installs, upgrades, lists and removes reviewed packages under a caller-supplied root.
Package store installs, upgrades, lists and removes reviewed packages under a caller-supplied root.
Package trust is the pure-Go reference for the C engine's scoped package trust records.
Package trust is the pure-Go reference for the C engine's scoped package trust records.

Jump to

Keyboard shortcuts

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