WebAssembly support in Tarantool via luawasm
#11793
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a new builtin module
luawasm
, which integrates WebAssembly components into Tarantool.At its core,
luawasm
is a Lua wrapper around the native runtime wasm.The native library provides a minimal low-level API:
load(path[, opts]) -> uid
- load a component from a.wasm
file.run(uid[, opts]) -> handle
- start the component usingwasi:cli/run
in a background thread.join(handle)
- wait for a background run to finish.call(uid, func, ...) -> any
- synchronously invoke an exported function.batch(uid, calls) -> table
- call multiple exports sequentially.drop(uid)
- unload a component.exports(uid) -> table
- enumerate available exports.The
luawasm
module is designed to make working with WebAssembly inside Tarantool convenient and natural for Lua developers. While the underlyingwasm.so
library exposes a low-level API,luawasm
wraps it into a higher-level, Lua-style interface with easy access to exported functions, component lifecycle helpers, and integration with Tarantool configuration.luawasm
Public API (high-level)
obj:help()
- print all available exports with signatures (including interface-scoped).obj:<export>(...)
- call a top-level exported function.obj:<export>:help()
- print the signature and docstring for<export>
.obj.iface.<iface>.<export>(...)
- call an export inside interface<iface>
.obj.iface.<iface>.<export>:help()
- print signature for that interface export.obj:batch({ {obj:<export>, a, b}, {obj.iface.<iface>.<export>, x} })
- run multiple calls in one worker.obj:run()
/obj:join()
- runwasi:cli/run
entry point in background and wait for completion.obj:meta()
- return component metadata (paths, world, language, etc.).obj:drop()
- unload the component and remove it from the registry.Integration with Tarantool config
Components can be described under
wasm.components
in YAML configuration and will be auto-loaded at startup intobox.wasm.components
. Access is unified viabox.wasm.get(name)
.Example: Lua usage
Example: Configuration usage
On startup: