wasm

package
v1.5.0-alpha4 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const WasmArch = 32
View Source
const WasmMaxPagesLimit = 1 << (WasmArch / 2)
View Source
const WasmPageSize = 65536

Variables

View Source
var (
	ActiveExecutions = lo.Must(telemetry.NewGauge(
		wasmExecutorMeter,
		"wasm_active_executions",
		"Number of active WASM executions",
	))
)

Functions

func ValidateModuleAsEntryPoint

func ValidateModuleAsEntryPoint(
	module wazero.CompiledModule,
	name string,
) error

ValidateModuleAsEntryPoint returns an error if the passed module is not capable of being an entry point to a job, i.e. that it contains a function of the passed name that meets the specification of:

- the named function exists and is exported - the function takes no parameters - the function returns one i32 value (exit code)

func ValidateModuleHasFunction

func ValidateModuleHasFunction(
	module wazero.CompiledModule,
	name string,
	parameters []api.ValueType,
	results []api.ValueType,
) error

ValidateModuleHasFunction returns an error if the passed module does not contain an exported function with the passed name, parameters and return values.

func ValidateModuleImports

func ValidateModuleImports(
	module wazero.CompiledModule,
	importModules ...wazero.CompiledModule,
) error

ValidateModuleImports will return an error if the passed module requires imports that are not found in any of the passed importModules. Imports have to match exactly, i.e. function names and signatures must be an exact match.

Types

type Executor

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

func NewExecutor

func NewExecutor() (*Executor, error)

func (*Executor) Cancel added in v1.0.4

func (e *Executor) Cancel(ctx context.Context, executionID string) error

Cancel tries to cancel a specific execution by its executionID. It returns an error if the execution is not found.

func (*Executor) GetLogStream added in v1.2.2

func (e *Executor) GetLogStream(ctx context.Context, request executor.LogStreamRequest) (io.ReadCloser, error)

GetOutputStream provides a stream of output logs for a specific execution. Parameters 'withHistory' and 'follow' control whether to include past logs and whether to keep the stream open for new logs, respectively. It returns an error if the execution is not found.

func (*Executor) IsInstalled

func (e *Executor) IsInstalled(context.Context) (bool, error)

func (*Executor) Run added in v0.3.24

Run initiates and waits for the completion of an execution in one call. This method serves as a higher-level convenience function that internally calls Start and Wait methods. It returns the result of the execution or an error if either starting or waiting fails, or if the context is canceled.

func (*Executor) ShouldBid added in v1.0.4

func (*Executor) ShouldBidBasedOnUsage added in v1.0.4

func (*Executor) ShouldBidBasedOnUsage(
	ctx context.Context,
	request bidstrategy.BidStrategyRequest,
	usage models.Resources,
) (bidstrategy.BidStrategyResponse, error)

func (*Executor) Start added in v1.0.4

func (e *Executor) Start(ctx context.Context, request *executor.RunCommandRequest) error

Start initiates an execution based on the provided RunCommandRequest.

func (*Executor) Wait added in v1.0.4

func (e *Executor) Wait(ctx context.Context, executionID string) (<-chan *models.RunCommandResult, <-chan error)

Wait initiates a wait for the completion of a specific execution using its executionID. The function returns two channels: one for the result and another for any potential error. If the executionID is not found, an error is immediately sent to the error channel. Otherwise, an internal goroutine (doWait) is spawned to handle the asynchronous waiting. Callers should use the two returned channels to wait for the result of the execution or an error. This can be due to issues either beginning the wait or in getting the response. This approach allows the caller to synchronize Wait with calls to Start, waiting for the execution to complete.

type ModuleLoader added in v0.3.26

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

ModuleLoader handles the loading of WebAssembly modules from storage.PreparedStorage and the automatic resolution of required imports.

ModuleLoader allows WebAssembly module dependencies to be specified within the WebAssembly program, allowing the user to deploy self-contained WebAssembly blobs. See the introductory talk at https://youtu.be/6zJkMLzXbQc.

This works by using the "module name" field of a WebAssmelby import header, (which for user-supplied modules is arbitrary) as a hint to the loader as to where the dependency lives and how to retrieve it. The module still needs to be specified as input data for the job (a previous implementation of the ModuleLoader could load modules from remote locations, but this one cannot).

func NewModuleLoader added in v0.3.26

func NewModuleLoader(runtime wazero.Runtime, config wazero.ModuleConfig, storages ...storage.PreparedStorage) *ModuleLoader

func (*ModuleLoader) InstantiateRemoteModule added in v0.3.26

func (loader *ModuleLoader) InstantiateRemoteModule(ctx context.Context, m storage.PreparedStorage) (api.Module, error)

InstantiateRemoteModule loads and instantiates the remote module and all of its dependencies. It only looks in the job's input storage specs for modules.

This function calls itself reucrsively for any discovered dependencies on the loaded modules, so that the returned module has all of its dependencies fully instantiated and is ready to use.

func (*ModuleLoader) Load added in v0.3.26

func (loader *ModuleLoader) Load(ctx context.Context, path string) (wazero.CompiledModule, error)

Load compiles and returns a module located at the passed path.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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