opendal icon indicating copy to clipboard operation
opendal copied to clipboard

idea: Provide OpenDAL as host functions for wasm runtimes

Open Xuanwo opened this issue 1 year ago • 2 comments

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-sdk that 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-sdk or calling opendal wasm api in their wasm code.
  • Using opendal-wasm-module to 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-unknown directly so users can use opendal in browser, tracked at https://github.com/apache/incubator-opendal/issues/3803
  • Compile to wasm32-wasi directly so users can use opendal in wasm runtime like wasmtime and wasmedge. (need to use crates like tokio-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?)

Xuanwo avatar Jan 11 '24 02:01 Xuanwo

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 avatar Jan 11 '24 02:01 Zheaoli

@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

Xuanwo avatar Jan 16 '24 15:01 Xuanwo

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.

Xuanwo avatar Apr 20 '25 05:04 Xuanwo