Documentation ¶
Index ¶
Constants ¶
const CustomSectionName = ".bufplugin"
CustomSectionName is the name of the custom wasm section we look into for buf extensions.
Variables ¶
This section is empty.
Functions ¶
func EncodeBufSection ¶
func EncodeBufSection(config *wasmpluginv1.ExecConfig) ([]byte, error)
EncodeBufSection encodes the ExecConfig message as a custom wasm section. The resulting bytes can be appended to any valid wasm file to add the new section to that file.
Types ¶
type CompiledPlugin ¶
type CompiledPlugin struct { // Metadata parsed from custom sections of the wasm file. May be nil if // no buf specific sections were found. ExecConfig *wasmpluginv1.ExecConfig // contains filtered or unexported fields }
CompiledPlugin is the compiled representation of loading wasm bytes.
func (*CompiledPlugin) ABI ¶
func (c *CompiledPlugin) ABI() wasmpluginv1.WasmABI
func (*CompiledPlugin) Close ¶ added in v1.17.0
func (c *CompiledPlugin) Close() error
type PluginExecutionError ¶
PluginExecutionError is a wrapper for WASM plugin execution errors.
func NewPluginExecutionError ¶
func NewPluginExecutionError(stderr string, exitcode uint32) *PluginExecutionError
NewPluginExecutionError constructs a new execution error.
func (*PluginExecutionError) Error ¶
func (e *PluginExecutionError) Error() string
type PluginExecutor ¶
type PluginExecutor interface { CompilePlugin(ctx context.Context, plugin []byte) (_ *CompiledPlugin, retErr error) Run(ctx context.Context, plugin *CompiledPlugin, stdin io.Reader, stdout io.Writer) (retErr error) }
PluginExecutor wraps a wazero end exposes functions to compile and run wasm plugins.
type PluginExecutorOption ¶
type PluginExecutorOption func(*WASMPluginExecutor)
PluginExecutorOption configuration options for the PluginExecutor.
func WithMemoryLimitPages ¶
func WithMemoryLimitPages(memoryLimitPages uint32) PluginExecutorOption
WithMemoryLimitPages provides a custom per memory limit for a plugin executor. The default is 8192 pages for 512MB.
type WASMPluginExecutor ¶
type WASMPluginExecutor struct {
// contains filtered or unexported fields
}
func NewPluginExecutor ¶
func NewPluginExecutor(compilationCacheDir string, options ...PluginExecutorOption) (*WASMPluginExecutor, error)
NewPluginExecutor creates a new pluginExecutor with a compilation cache dir and other buf defaults.
func (*WASMPluginExecutor) CompilePlugin ¶
func (e *WASMPluginExecutor) CompilePlugin(ctx context.Context, plugin []byte) (_ *CompiledPlugin, retErr error)
CompilePlugin takes a byte slice with a valid wasm module, compiles it and optionally reads out buf plugin metadata.