idea: Provide OpenDAL as host functions for wasm runtimes
As demonstrated in @Zheaoli's opendal-wasmedge-demo, we can offer opendal as host functions for all of wasmtime, wasmedge and wasmer.
We can have the following design:
- opendal will provide an
opendal-wasm-sdkthat exposes our wasm API. Users can use the sdk across different supported runtime. - opendal will provide host function modules for different wasm runtimes in
opendal-wasm-module.
With those crates support, users can use opendal in this way:
- Import
opendal-wasm-sdkor calling opendal wasm api in their wasm code. - Using
opendal-wasm-moduleto register host functions. - Load wasm code.
There are many ways to integrate with WASM, and OpenDAL plans to support for the following:
- Compile to
wasm32-unknown-unknowndirectly so users can use opendal in browser, tracked at https://github.com/apache/incubator-opendal/issues/3803 - Compile to
wasm32-wasidirectly so users can use opendal in wasm runtime like wasmtime and wasmedge. (need to use crates liketokio-wasi, not started) - Split into host functions and client sdk, users will need to load functions when they start the runtime (this issue).
- Integrate into runtimes directly that replace their fs implementation. (Is this possible?)
Maybe I can propose more design details this week.
BTW, about the opendal-wasm-sdk, we can take a look at proxy-wasm-rust-sdk, FYI https://github.com/proxy-wasm/proxy-wasm-rust-sdk
@Zheaoli also mentioned a new way: https://wasmedge.org/docs/contribute/source/plugin/process
Provide a wasmedge plugin so users can:
wasmedge --dir .:. --reactor --process_plugin libopendal_wasmedge_plugin.so your_wasm_file.wasm
No action required at this time, so I’m closing this for now. Please feel free to reopen it if you believe further work is needed.