wasm

package
v0.3.26 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateModuleAgainstJob

func ValidateModuleAgainstJob(
	module wazero.CompiledModule,
	job model.Spec,
	importModules ...wazero.CompiledModule,
) error

ValidateModuleAgainstJob will return an error if the passed job does not represent a valid WASM executor job or the passed module is not able to be run to fulfill the job.

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 {
	StorageProvider storage.StorageProvider
}

func NewExecutor

func NewExecutor(_ context.Context, storageProvider storage.StorageProvider) (*Executor, error)

func (*Executor) GetBidStrategy added in v0.3.24

func (*Executor) GetBidStrategy(context.Context) (bidstrategy.BidStrategy, error)

GetBidStrategy implements executor.Executor

func (*Executor) GetOutputStream added in v0.3.25

func (e *Executor) GetOutputStream(ctx context.Context, executionID string, withHistory bool, follow bool) (io.ReadCloser, error)

func (*Executor) GetVolumeSize

func (e *Executor) GetVolumeSize(ctx context.Context, volume model.StorageSpec) (uint64, error)

func (*Executor) HasStorageLocally

func (e *Executor) HasStorageLocally(ctx context.Context, volume model.StorageSpec) (bool, error)

func (*Executor) IsInstalled

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

func (*Executor) Run added in v0.3.24

func (e *Executor) Run(ctx context.Context, executionID string, job model.Job, jobResultsDir string) (*model.RunCommandResult, error)

type ModuleLoader added in v0.3.26

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

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

func NewModuleLoader added in v0.3.26

func NewModuleLoader(runtime wazero.Runtime, config wazero.ModuleConfig, proivder storage.StorageProvider) *ModuleLoader

func (*ModuleLoader) InstantiateRemoteModule added in v0.3.26

func (loader *ModuleLoader) InstantiateRemoteModule(ctx context.Context, spec model.StorageSpec) (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.

func (*ModuleLoader) LoadRemoteModules added in v0.3.26

func (loader *ModuleLoader) LoadRemoteModules(ctx context.Context, specs ...model.StorageSpec) ([]wazero.CompiledModule, error)

LoadRemoteModules loads and compiles all of the modules located by the passed storage specs.

Jump to

Keyboard shortcuts

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