Documentation
¶
Overview ¶
Package hashicorp binds Ext's shared plugin endpoint to HashiCorp go-plugin. This library backend owns go-plugin's handshake, RPC bindings, dispensing, and client cleanup. Domain semantics remain in the consumer's plugin.Guest.
Index ¶
- Constants
- func Connect(ctx context.Context, client *hc.Client) (plugin.Backend, error)
- func ConnectCommand(ctx context.Context, command *exec.Cmd, protocol string) (plugin.Backend, error)
- func ConnectInterface(ctx context.Context, client *hc.Client, name string, ...) (plugin.Backend, error)
- func ConnectProcess(ctx context.Context, p Process) (plugin.Backend, error)
- func GRPCProfile() plugin.BackendProfile
- func GRPCServer(options []grpc.ServerOption) *grpc.Server
- func HandshakeConfig() hc.HandshakeConfig
- func JSONLineBridge(protocol string) (interop.Bridge, error)
- func NetRPCProfile() plugin.BackendProfile
- func Serve(guest plugin.Endpoint, protocol string) error
- type Plugin
- func (*Plugin) Client(_ *hc.MuxBroker, client *rpc.Client) (interface{}, error)
- func (*Plugin) GRPCClient(ctx context.Context, _ *hc.GRPCBroker, conn *grpc.ClientConn) (interface{}, error)
- func (p *Plugin) GRPCServer(_ *hc.GRPCBroker, server *grpc.Server) error
- func (p *Plugin) Server(*hc.MuxBroker) (interface{}, error)
- type Process
Constants ¶
const PluginName = "ext"
PluginName is the Ext backend dispense key.
Variables ¶
This section is empty.
Functions ¶
func Connect ¶
Connect starts/connects a dedicated go-plugin client and dispenses the Ext interface. Call it inside plugin.Options.Connect, after trust verification. Ownership transfers here: failures kill the client, and the returned backend kills it on Close. Never also supervise that child with the ledger supervisor (pkg/ext-go/cengine/ledger/supervisor). Configure ClientConfig.StartTimeout: cancellation returns promptly, but cleanup of a pending native startup waits for go-plugin's startup to return.
func ConnectCommand ¶
func ConnectCommand(ctx context.Context, command *exec.Cmd, protocol string) (plugin.Backend, error)
ConnectCommand binds an explicitly supplied command to the selected transport. The caller has already verified selection and command/wrapper artifacts. This permits lifecycle wrappers without adding product behavior to the library. Cmd and its streams become go-plugin owned. Never share it across sessions.
func ConnectInterface ¶
func ConnectInterface(ctx context.Context, client *hc.Client, name string, bind func(interface{}) (plugin.Backend, error)) (plugin.Backend, error)
ConnectInterface supports an existing go-plugin interface with a consumer-supplied translation to Backend. The translation owns its domain contract and must honor Backend cancellation and handshake requirements. It shares Connect's dedicated-client ownership and cleanup behavior.
func ConnectProcess ¶
ConnectProcess verifies pinned executable content immediately before starting. The application still verifies provenance and protects immutable paths against replacement. Connect owns cleanup; it is not a process-tree supervisor.
func GRPCProfile ¶
func GRPCProfile() plugin.BackendProfile
func GRPCServer ¶
func GRPCServer(options []grpc.ServerOption) *grpc.Server
GRPCServer is a go-plugin ServeConfig.GRPCServer factory with explicit wire limits. It preserves upstream TLS options. JSON inside BytesValue remains bounded separately to MaxFrameBytes on both sides.
func HandshakeConfig ¶
func HandshakeConfig() hc.HandshakeConfig
HandshakeConfig returns a copy of the backend's native handshake. The cookie identifies a compatible launch convention; it provides no authentication.
func JSONLineBridge ¶
JSONLineBridge declares the mechanics of the supplied stdio bridge. Native streaming/callbacks do not cross it; declared unary/pull-stream contracts do.
func NetRPCProfile ¶
func NetRPCProfile() plugin.BackendProfile
func Serve ¶
Serve serves guest as a go-plugin plugin on this process's stdio and returns when the host disconnects. protocol is "grpc" or "netrpc" and must match what the host allows. Call it once from the plugin's main.
go-plugin owns the handshake and the connection. Its logger is silenced: stdout carries the handshake and stderr is the diagnostic channel, so the guest writes there itself. A plugin author needs no go-plugin or go-hclog import; a program that wants other go-plugin options builds its own hc.ServeConfig from HandshakeConfig, PluginName, Plugin and GRPCServer.
Types ¶
type Plugin ¶
Plugin implements both go-plugin bindings. Hosts leave Guest nil; plugins supply a shared Endpoint (a Guest or a verified bridge Relay). Configure AllowedProtocols explicitly on the host and use GRPCServer on the guest to select gRPC. Each dispensed object is a Backend.
func (*Plugin) GRPCClient ¶
func (*Plugin) GRPCClient(ctx context.Context, _ *hc.GRPCBroker, conn *grpc.ClientConn) (interface{}, error)
func (*Plugin) GRPCServer ¶
type Process ¶
type Process struct {
Executable string `json:"executable"`
SHA256 string `json:"sha256"`
Protocol string `json:"protocol"`
Arguments []string `json:"arguments,omitempty"`
Environment []string `json:"environment,omitempty"`
}
Process is a reviewed launch selection. SHA256 pins bytes, not publisher identity; the application must authenticate this configuration separately. Environment is explicit: the parent environment is not inherited.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
ext-plugin
command
ext-plugin inspects portable packages without loading or executing plugins.
|
ext-plugin inspects portable packages without loading or executing plugins. |