Documentation
¶
Index ¶
- type ClientConfig
- type Config
- type GRPCBroker
- type GRPCConfig
- type Handle
- func (h *Handle) Client() any
- func (h *Handle) Close(ctx context.Context) error
- func (h *Handle) Info() Info
- func (h *Handle) PluginPath() string
- func (h *Handle) ReadFile(resource string) ([]byte, error)
- func (h *Handle) ResolvePath(resource string) (string, error)
- func (h *Handle) RootPath() string
- type HandshakeConfig
- type Info
- type Manager
- type Protocol
- type WASMClientConfig
- type WASMConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientConfig ¶
type ClientConfig = hcplugin.ClientConfig
type Config ¶
type Config struct {
TempDir string
GRPC *GRPCConfig
WASM *WASMConfig
}
type GRPCBroker ¶ added in v0.1.2
type GRPCBroker struct {
// contains filtered or unexported fields
}
GRPCBroker wraps hashicorp go-plugin broker for host-side usage.
func (*GRPCBroker) AcceptAndServe ¶ added in v0.1.2
func (b *GRPCBroker) AcceptAndServe(id uint32, register func(*grpc.Server))
AcceptAndServe serves a gRPC server on broker stream id.
func (*GRPCBroker) NextID ¶ added in v0.1.2
func (b *GRPCBroker) NextID() uint32
NextID returns a unique broker stream ID.
type GRPCConfig ¶
type GRPCConfig struct {
HandshakeConfig HandshakeConfig
RunAsUser string
// SkipHostEnv prevents the plugin process from inheriting the host
// process environment. go-plugin still supplies the environment values
// required to establish its handshake.
//
// It defaults to false to preserve the existing behavior.
SkipHostEnv bool
AllowedProtocols []Protocol
Stderr io.Writer
SyncStdout io.Writer
SyncStderr io.Writer
// Loader is used by the default gRPC preset.
// If nil, the preset returns *grpc.ClientConn as client.
Loader func(ctx context.Context, conn *grpc.ClientConn) (any, error)
// LoaderWithBroker is used by the default gRPC preset.
// If set, it takes precedence over Loader and receives GRPCBroker.
LoaderWithBroker func(ctx context.Context, broker *GRPCBroker, conn *grpc.ClientConn) (any, error)
ClientConfigOverride func(*ClientConfig)
}
type Handle ¶
type Handle struct {
// contains filtered or unexported fields
}
func (*Handle) PluginPath ¶
func (*Handle) ReadFile ¶ added in v0.1.1
ReadFile reads bytes from a plugin resource under Content.
func (*Handle) ResolvePath ¶ added in v0.1.1
ResolvePath maps a plugin resource reference to an absolute file path under Content.
The resource can be one of: - "/greet.txt" - "greet.txt" - "Content/greet.txt" - "<plugin-file>.plg/Content/greet.txt"
type HandshakeConfig ¶
type Info ¶
type Protocol ¶
type Protocol string
const (
ProtocolGRPC Protocol = Protocol(hcplugin.ProtocolGRPC)
)
type WASMClientConfig ¶ added in v0.2.0
type WASMClientConfig struct {
// NewRuntime creates a new wazero runtime for one plugin instance.
// It must install any required host modules, such as WASI.
NewRuntime func(context.Context) (wazero.Runtime, error)
// ModuleConfig configures the WebAssembly module instance.
ModuleConfig wazero.ModuleConfig
}
WASMClientConfig contains wazero settings shared with a WASM Loader. A fresh runtime must be created for each loaded plugin.
type WASMConfig ¶
type WASMConfig struct {
// Loader receives the resolved module path, plugin metadata, and the
// WASM client configuration after ClientConfigOverride has been applied.
// It returns:
// 1) plugin client instance used by caller
// 2) cleanup function invoked on Unload
Loader func(ctx context.Context, modulePath string, info Info, clientConfig *WASMClientConfig) (client any, cleanup func(context.Context) error, err error)
// ClientConfigOverride customizes the wazero runtime and module settings
// before Loader creates a contract-specific WASM client.
ClientConfigOverride func(*WASMClientConfig)
}
Click to show internal directories.
Click to hide internal directories.