Documentation
¶
Index ¶
- Variables
- type Compiler
- type Executable
- type FunctionalOption
- func WithContext(ctx context.Context) FunctionalOption
- func WithEntryPoint(entryPoint string) FunctionalOption
- func WithHostFunctions(funcs []extismSDK.HostFunction) FunctionalOption
- func WithLogHandler(handler slog.Handler) FunctionalOption
- func WithLogger(logger *slog.Logger) FunctionalOption
- func WithRuntimeConfig(config wazero.RuntimeConfig) FunctionalOption
- func WithWASIEnabled(enabled bool) FunctionalOption
Constants ¶
This section is empty.
Variables ¶
var ( ErrBytecodeNil = errors.New("wasm bytecode is nil") ErrContentNil = errors.New("wasm content is nil") ErrExecCreationFailed = errors.New("unable to create wasm executable") ErrValidationFailed = errors.New("wasm script validation error") )
var ErrExecutableClosed = errors.New("executable is closed")
Functions ¶
This section is empty.
Types ¶
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
Compiler implements the script.Compiler interface for WASM modules
func New ¶
func New(opts ...FunctionalOption) (*Compiler, error)
New creates a new Extism WASM Compiler instance with the provided options.
func (*Compiler) Compile ¶
func (c *Compiler) Compile(scriptReader io.ReadCloser) (script.ExecutableContent, error)
Compile implements script.Compiler TODO: Some error paths are difficult to test with the current design Consider adding integration tests for hard-to-reach error cases.
func (*Compiler) GetEntryPointName ¶
GetEntryPointName is a getter for the func name entrypoint
type Executable ¶
type Executable struct { ByteCode adapters.CompiledPlugin // contains filtered or unexported fields }
Executable implements script.ExecutableContent for Extism WASM modules
func NewExecutable ¶
func NewExecutable( scriptBytes []byte, byteCode adapters.CompiledPlugin, entryPoint string, ) *Executable
NewExecutable creates a new Executable instance
func (*Executable) Close ¶
func (e *Executable) Close(ctx context.Context) error
Close implements io.Closer
func (*Executable) GetByteCode ¶
func (e *Executable) GetByteCode() any
GetByteCode returns the compiled plugin as a generic interface
func (*Executable) GetEntryPoint ¶
func (e *Executable) GetEntryPoint() string
GetEntryPoint returns the name of the entry point function
func (*Executable) GetExtismByteCode ¶
func (e *Executable) GetExtismByteCode() adapters.CompiledPlugin
GetExtismByteCode returns the compiled plugin with its proper type
func (*Executable) GetMachineType ¶
func (e *Executable) GetMachineType() machineTypes.Type
GetMachineType returns the Extism machine type
func (*Executable) GetSource ¶
func (e *Executable) GetSource() string
GetSource returns the original script content
type FunctionalOption ¶
FunctionalOption is a function that configures a Compiler instance
func WithContext ¶
func WithContext(ctx context.Context) FunctionalOption
WithContext creates an option to set a custom context for the Extism compiler.
func WithEntryPoint ¶
func WithEntryPoint(entryPoint string) FunctionalOption
WithEntryPoint creates an option to set the entry point for Extism WASM modules
func WithHostFunctions ¶
func WithHostFunctions(funcs []extismSDK.HostFunction) FunctionalOption
WithHostFunctions creates an option to set additional host functions
func WithLogHandler ¶
func WithLogHandler(handler slog.Handler) FunctionalOption
WithLogHandler creates an option to set the log handler for Extism compiler. This is the preferred option for logging configuration as it provides more flexibility through the slog.Handler interface.
func WithLogger ¶
func WithLogger(logger *slog.Logger) FunctionalOption
WithLogger creates an option to set a specific logger for Extism compiler. This is less flexible than WithLogHandler but allows users to customize their logging group configuration.
func WithRuntimeConfig ¶
func WithRuntimeConfig(config wazero.RuntimeConfig) FunctionalOption
WithRuntimeConfig creates an option to set a custom wazero runtime configuration
func WithWASIEnabled ¶
func WithWASIEnabled(enabled bool) FunctionalOption
WithWASIEnabled creates an option to enable or disable WASI support