diff options
author | Andrew Clayton <a.clayton@nginx.com> | 2024-02-05 21:50:52 +0000 |
---|---|---|
committer | Andrew Clayton <a.clayton@nginx.com> | 2024-02-21 16:20:32 +0000 |
commit | 07a0c9a34817d6faedff67505507cd4f54752a22 (patch) | |
tree | 998ea43d529b19154e9fba69d1045028c3958673 /src/nxt_application.c | |
parent | 8d030139a1bde3ee640852d1348eb595cb376d05 (diff) | |
download | unit-07a0c9a34817d6faedff67505507cd4f54752a22.tar.gz unit-07a0c9a34817d6faedff67505507cd4f54752a22.tar.bz2 |
Wasm-wc: Wire up the language module to the config system
This exposes the various WebAssembly Component Model language module
specific options.
The application type is "wasm-wasi-component".
There is a "component" option that is required, this specifies the full
path to the WebAssembly component to be run. This component should be in
binary format, i.e a .wasm file.
There is also currently one optional option
"access"
Due to the sandboxed nature of WebAssembly, by default Wasm
modules/components don't have any access to the underlying filesystem.
There is however a capabilities based mechanism[0] for allowing such
access.
This adds a config option to the 'wasm-wasi-component' application type
(same as for 'wasm');
'access.filesystem' which takes an array of
directory paths that are then made available to the wasm
module/component. This access works recursively, i.e everything under a
specific path is allowed access to.
Example config might look like
"applications": {
"my-wasm-component": {
"type": "wasm-wasi-component",
"component": "/path/to/component.wasm",
"access" {
"filesystem": [
"/tmp",
"/var/tmp"
]
}
}
}
The actual mechanism used allows directories to be mapped differently in
the guest. But at the moment we don't support that and just map say /tmp
to /tmp. This can be revisited if it's something users clamour for.
[0]: <https://github.com/bytecodealliance/wasmtime/blob/main/docs/WASI-capabilities.md>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to 'src/nxt_application.c')
-rw-r--r-- | src/nxt_application.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/nxt_application.c b/src/nxt_application.c index 872e387a..e0247bf0 100644 --- a/src/nxt_application.c +++ b/src/nxt_application.c @@ -1100,6 +1100,9 @@ nxt_app_parse_type(u_char *p, size_t length) } else if (nxt_str_eq(&str, "java", 4)) { return NXT_APP_JAVA; + } else if (nxt_str_eq(&str, "wasm-wasi-component", 19)) { + return NXT_APP_WASM_WC; + } else if (nxt_str_eq(&str, "wasm", 4)) { return NXT_APP_WASM; } |