This repository has been archived by the owner on Dec 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixes, README, rpc-error type * Export RpcError
- Loading branch information
Showing
9 changed files
with
229 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# golem-wasm-rpc-stubgen | ||
|
||
The `golem-wasm-rpc-stubgen` is a CLI tool to generate the RPC stubs from a component's WIT definition. | ||
|
||
```shell | ||
Usage: wasm-rpc-stubgen generate [OPTIONS] --source-wit-root <SOURCE_WIT_ROOT> --dest-crate-root <DEST_CRATE_ROOT> | ||
|
||
Options: | ||
-s, --source-wit-root <SOURCE_WIT_ROOT> | ||
-d, --dest-crate-root <DEST_CRATE_ROOT> | ||
-w, --world <WORLD> | ||
--stub-crate-version <STUB_CRATE_VERSION> [default: 0.0.1] | ||
--wasm-rpc-path-override <WASM_RPC_PATH_OVERRIDE> | ||
-h, --help Print help | ||
-V, --version Print version | ||
``` | ||
|
||
- `source-wit-root`: The root directory of the component's WIT definition to be called via RPC | ||
- `dest-crate-root`: The target path to generate a new stub crate to | ||
- `world`: The world name to be used in the generated stub crate. If there is only a single world in the source root | ||
package, no need to specify. | ||
- `stub-crate-version`: The crate version of the generated stub crate | ||
- `wasm-rpc-path-override`: The path to the `wasm-rpc` crate to be used in the generated stub crate. If not specified, | ||
the latest version of `wasm-rpc` will be used. | ||
|
||
The command creates a new Rust crate that is ready to be compiled with | ||
|
||
```shell | ||
cargo component build --release | ||
``` | ||
|
||
The resulting WASM component implements the **stub interface** corresponding to the source interface, found in the | ||
target directory's | ||
`wit/_stub.wit` file. This WASM component is to be composed together with another component that calls the original | ||
interface via WASM RPC. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# golem-wasm-rpc | ||
|
||
Defines data types for [Golem](https://golem.cloud)'s remote function invocation and conversions between them. | ||
|
||
- `WitValue` is the WIT-defined generic data type capable of representing an arbitrary value, generated by `wit-bindgen` | ||
- A builder and an extractor API for `WitValue` | ||
- `Value` is a recursive Rust type which is more convenient to work with than `WitValue`. Conversion between `WitValue` and `Value` is implemented in both directions. | ||
- Protobuf message types for describing values and types, and a protobuf version of `WitValue` itself and conversion from and to `Value` and `WitValue` | ||
- JSON representation of WIT values, as defined in [the Golem docs](https://learn.golem.cloud/docs/template-interface). | ||
- Conversion of `Value` to and from `wasmtime` values | ||
|
||
The JSON representation requires additional type information which can be extracted using the [golem-wasm-ast](https://crates.io/crates/golem-wasm-ast) crate. | ||
|
||
## Host and stub mode | ||
|
||
The `golem-wasm-rpc` crate can be both used in host and guest environments: | ||
|
||
To compile the host version: | ||
|
||
```shell | ||
cargo build -p wasm-rpc --no-default-features --features host | ||
``` | ||
|
||
To compile the guest version, has minimal dependencies and feature set to be used in generated stubs: | ||
|
||
```shell | ||
cargo component build -p wasm-rpc --no-default-features --features stub | ||
``` | ||
|
||
## Feature flags | ||
- `arbitrary` adds an `Arbitrary` instance for `Value` | ||
- `json` adds conversion functions for mapping of a WIT value and type definition to/from JSON | ||
- `protobuf` adds the protobuf message types | ||
- `wasmtime` adds conversion to `wasmtime` `Val` values | ||
- `host` enables all features: `arbitrary`, `json`, `protobuf`, `typeinfo`, and `wasmtime` | ||
- `stub` is to be used in generated WASM stubs and disables all features, and generates guest bindings instead of host bindings |
Oops, something went wrong.