imports

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2023 License: Apache-2.0 Imports: 17 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectExtensions added in v0.2.0

func DetectExtensions(module wazero.CompiledModule) (ext []wasi_snapshot_preview1.Extension)

DetectExtensions detects extensions to WASI preview 1.

func DetectSocketsExtension added in v0.2.0

func DetectSocketsExtension(module wazero.CompiledModule) *wasi_snapshot_preview1.Extension

DetectSocketsExtension determines the sockets extension in use by inspecting a WASM module's host imports.

This function can detect WasmEdge v1 and WasmEdge v2.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder is used to setup and instantiate the WASI host module.

func NewBuilder

func NewBuilder() *Builder

NewBuilder creates a Builder.

func (*Builder) Instantiate

func (b *Builder) Instantiate(ctx context.Context, runtime wazero.Runtime) (ctxret context.Context, system wasi.System, err error)

Instantiate compiles and instantiates the WASI module and binds it to the specified context.

func (*Builder) WithArgs

func (b *Builder) WithArgs(args ...string) *Builder

WithArgs sets command line arguments.

func (*Builder) WithDecorators

func (b *Builder) WithDecorators(decorators ...wasi_snapshot_preview1.Decorator) *Builder

WithDecorators sets the host module decorators.

func (*Builder) WithDials

func (b *Builder) WithDials(dials ...string) *Builder

WithDials specifies a list of addresses to dial before starting the module. The connection sockets are added to the set of preopens.

func (*Builder) WithDirs

func (b *Builder) WithDirs(dirs ...string) *Builder

WithDirs specifies a set of directories to preopen.

The directory can either be a path, or a string of the form "path:path[:ro]" for compatibility with wazero's WASI preview 1 host module. Since virtual file systems are not supported by this implementation, the two paths must be the same when using this syntax. The optional ":ro" prefix means that this directory is read-only.

func (*Builder) WithEnv

func (b *Builder) WithEnv(env ...string) *Builder

WithEnv sets environment variables.

func (*Builder) WithExit

func (b *Builder) WithExit(fn func(context.Context, int) error) *Builder

WithExit sets the proc_exit function.

func (*Builder) WithListens

func (b *Builder) WithListens(listens ...string) *Builder

WithListens specifies a list of addresses to listen on before starting the module. The listener sockets are added to the set of preopens.

func (*Builder) WithMonotonicClock

func (b *Builder) WithMonotonicClock(clock func(context.Context) (uint64, error), precision time.Duration) *Builder

WithMonotonicClock sets the monotonic clock and precision.

func (*Builder) WithName

func (b *Builder) WithName(name string) *Builder

WithName sets the name of the module, which is exposed to the module as argv[0].

func (*Builder) WithNonBlockingStdio

func (b *Builder) WithNonBlockingStdio(enable bool) *Builder

WithNonBlockingStdio enables or disables non-blocking stdio. When enabled, stdio file descriptors will have the O_NONBLOCK flag set before the module is started.

func (*Builder) WithRaise

func (b *Builder) WithRaise(fn func(context.Context, int) error) *Builder

WithRaise sets the proc_raise function.

func (*Builder) WithRealtimeClock

func (b *Builder) WithRealtimeClock(clock func(context.Context) (uint64, error), precision time.Duration) *Builder

WithRealtimeClock sets the realtime clock and precision.

func (*Builder) WithSocketsExtension

func (b *Builder) WithSocketsExtension(name string, module wazero.CompiledModule) *Builder

WithSocketsExtension enables a sockets extension.

The name can be one of: - none: disable sockets extensions (use vanilla WASI preview 1) - wasmedgev1: use WasmEdge sockets extension version 1 - wasmedgev2: use WasmEdge sockets extension version 2 - path_open: use the extension to the path_open system call (unix.PathOpenSockets) - auto: attempt to detect one of the extensions above

func (*Builder) WithStdio

func (b *Builder) WithStdio(stdin, stdout, stderr int) *Builder

WithStdio sets stdio file descriptors.

Note that the file descriptors will be duplicated before the module takes ownership. The caller is responsible for managing the specified descriptors.

func (*Builder) WithTracer

func (b *Builder) WithTracer(enable bool, w io.Writer) *Builder

WithTracer enables the Tracer, and instructs it to write to the specified io.Writer.

func (*Builder) WithWrappers

func (b *Builder) WithWrappers(wrappers ...func(wasi.System) wasi.System) *Builder

WithWrappers sets the wasi.System wrappers.

func (*Builder) WithYield

func (b *Builder) WithYield(fn func(context.Context) error) *Builder

WithYield sets the sched_yield function.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL