rvolosatovs opened PR #8737 from rvolosatovs:feat/wasmtime-rpc
to bytecodealliance:main
:
This is the first step in RPC-based Wasmtime plugin functionality support based on https://github.com/wrpc/wrpc
I will update this PR with more info going forward, but in short
wasmtime-rpc
, using wRPC, provides a way to extend the host runtime using interfaces defined in WIT without statically-generated bindings.
wRPC encodes values using Component Model Value Encoding (https://github.com/WebAssembly/component-model/pull/336) on the wire - this encoding is implemented in this PR directly using wasmtime values and types. The implementation depends on https://docs.rs/wasm-tokio/latest/wasm_tokio/ developed by me in https://github.com/wrpc/wasm-tokiowRPC is built on top of a core "transport" abstraction, which provides a bidirectional, multiplexed byte streams.
Best supported wRPC transport is currently based on https://nats.io/ (implementation available at https://github.com/wrpc/wrpc/blob/86d06a487f3ab3ad71c476c0038dbb759282388a/crates/transport-nats/src/lib.rs), but IPC transport is currently underway and the protocol is completely transport-agnostic.
You can see a basic "static" outgoing transport implemented in the test.The end goal here is that developers should be able to choose the "polyfill strategy" having a way to e.g. polyfill every component import missing from the linker, or a particular instance import etc. For this first step, I've only added functionality to polyfill a single function at a time given a linker instance, instance name, function name and its' type.
I've decided to omit the resource support from this PR, which is currently being redesigned in wRPC https://github.com/wrpc/wrpc/issues/101.
Note, wRPC contains a subtree-merged
wit-bindgen
adaptation with support for Go and Rust, but they are currently out-of-sync with latest CM value encoding spec (mostly around flag and char encoding).wRPC fully supports async proposal as it currently stands, i.e. native
future
andstream
types. An example WIT: https://github.com/wrpc/http/blob/5b9a324c74d72b27d8559c54b419a54609d01c68/examples/go/http-outgoing-client/wit/deps/wrpc-http/types.wit#L16-L38 and example usage of generated bindings in Go https://github.com/wrpc/http/blob/5b9a324c74d72b27d8559c54b419a54609d01c68/examples/go/http-outgoing-client/cmd/http-outgoing-client-nats/main.go#L38-L68
rvolosatovs edited PR #8737:
This is the first step in RPC-based Wasmtime plugin functionality support based on https://github.com/wrpc/wrpc
I will update this PR with more info going forward, but in short
wasmtime-rpc
, using wRPC, provides a way to extend the host runtime using interfaces defined in WIT without statically-generated bindings.
wRPC encodes values using Component Model Value Encoding (https://github.com/WebAssembly/component-model/pull/336) on the wire - this encoding is implemented in this PR directly using wasmtime values and types. The implementation depends on https://docs.rs/wasm-tokio/latest/wasm_tokio/ developed by me in https://github.com/wrpc/wasm-tokiowRPC is built on top of a core "transport" abstraction, which provides bidirectional, multiplexed byte streams.
Best supported wRPC transport is currently based on https://nats.io/ (implementation available at https://github.com/wrpc/wrpc/blob/86d06a487f3ab3ad71c476c0038dbb759282388a/crates/transport-nats/src/lib.rs), but IPC transport is currently underway and the protocol is completely transport-agnostic.
You can see a basic "static" outgoing transport implemented in the test.The end goal here is that developers should be able to choose the "polyfill strategy" having a way to e.g. polyfill every component import missing from the linker, or a particular instance import etc. For this first step, I've only added functionality to polyfill a single function at a time given a linker instance, instance name, function name and its' type.
I've decided to omit the resource support from this PR, which is currently being redesigned in wRPC https://github.com/wrpc/wrpc/issues/101.
Note, wRPC contains a subtree-merged
wit-bindgen
adaptation with support for Go and Rust, but they are currently out-of-sync with latest CM value encoding spec (mostly around flag and char encoding).wRPC fully supports async proposal as it currently stands, i.e. native
future
andstream
types. An example WIT: https://github.com/wrpc/http/blob/5b9a324c74d72b27d8559c54b419a54609d01c68/examples/go/http-outgoing-client/wit/deps/wrpc-http/types.wit#L16-L38 and example usage of generated bindings in Go https://github.com/wrpc/http/blob/5b9a324c74d72b27d8559c54b419a54609d01c68/examples/go/http-outgoing-client/cmd/http-outgoing-client-nats/main.go#L38-L68
rvolosatovs updated PR #8737.
Last updated: Dec 23 2024 at 13:07 UTC