wasm

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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) GetOutputStream added in v0.3.25

func (e *Executor) GetOutputStream(ctx context.Context, executionID string, withHistory bool, follow bool) (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.

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. To do this, it attempts to parse the import module name as a storage location and retrieves the module from there.

For example, a WASM module specifies an import:

(import "QmPympgyrEGEdSJ93rqvQkR71QLuQGdhKQtYztFwxpQsid" "easter" (func $easter (type 4)))

InstantiateRemoteModule will recognize the module name as a CID and attempt to load the module via IPFS. URLs are also supported.

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 comiples 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