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
- type Options
- type Process
- func (p *Process) Call(ctx context.Context, method string, params any, result any) error
- func (p *Process) CallProgress(ctx context.Context, method string, params any, result any, ...) error
- func (p *Process) Close() error
- func (p *Process) Descriptor() plugin.Descriptor
- func (p *Process) Done() <-chan struct{}
- func (p *Process) Stderr() string
- type ReverseOptions
Constants ¶
const DefaultTimeout = 10 * time.Minute
DefaultTimeout bounds handshake and calls without an earlier caller deadline.
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 {
// 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 ¶
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 (*Process) Call ¶
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) Descriptor ¶
func (p *Process) Descriptor() plugin.Descriptor
Descriptor is a copy of the session's reviewed descriptor.
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.
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. |
|
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. |