Skip to content

Commit 86980d6

Browse files
committed
doc: fix formatting
Signed-off-by: Roman Volosatovs <[email protected]>
1 parent 1ce2019 commit 86980d6

File tree

1 file changed

+52
-36
lines changed

1 file changed

+52
-36
lines changed

README.md

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -39,100 +39,116 @@ wRPC fully supports the unreleased native [WIT] `stream` and `future` data types
3939

4040
## Quickstart
4141

42-
wRPC usage examples for different programming languages can be found at [./examples](./examples).
42+
wRPC usage examples for different programming languages can be found at [examples](./examples).
4343

4444
There are 2 different kinds of examples:
4545
- Native wRPC applications, tied to a particular wRPC transport (currently, NATS only)
4646
- Generic Wasm components, that need to run in a Wasm runtime. Those can be executed, for example, using `wrpc-wasmtime-nats`, to polyfill imports at runtime and serve exports using wRPC.
4747

48-
Here is a guide demonstrating how to bootstrap the Rust Wasm component example implemented by:
49-
- [examples/rust/hello-component-server](examples/rust/hello-component-server)
50-
- [examples/rust/hello-component-client](examples/rust/hello-component-client)
51-
5248
### `hello` example
5349

54-
In this example we will serve and invoke a simple [`hello`](./examples/wit/hello/hello.wit) application
50+
In this example we will serve and invoke a simple [`hello`](./examples/wit/hello/hello.wit) application using:
51+
52+
- [examples/rust/hello-component-client](examples/rust/hello-component-client)
53+
- [examples/rust/hello-component-server](examples/rust/hello-component-server)
54+
- [examples/rust/hello-nats-client](examples/rust/hello-nats-client)
55+
- [examples/rust/hello-nats-server](examples/rust/hello-nats-server)
5556

5657
#### Requirements
58+
5759
- `nats-server` >= 2.10.20 or `docker` >= 24.0.6 (or any other OCI runtime)
5860
- `rust` >= 1.80.1
5961

6062
#### How-To
6163

62-
In this example we will be using `wasm32-wasip1` target, which is available in stable Rust and configured in [`rust-toolchain.toml`](./rust-toolchain.toml) in the root of this repository. [`wasm32-wasip2`](https://doc.rust-lang.org/nightly/rustc/platform-support/wasm32-wasip2.html) can be used as well.
64+
In the steps below, `wasm32-wasip1` target will be used, because it is currently available in stable Rust and also conveniently configured in [`rust-toolchain.toml`](./rust-toolchain.toml) in the root of this repository.
65+
[`wasm32-wasip2`](https://doc.rust-lang.org/nightly/rustc/platform-support/wasm32-wasip2.html) can be used instead, if desired.
66+
67+
1. Build Wasm `hello` client:
6368

64-
1. Build the client Wasm component:
6569
```sh
6670
cargo build --release -p hello-component-client --target wasm32-wasip1
6771
```
6872

69-
> Output is in target/wasm32-wasip1/release/hello-component-client.wasm
73+
> Output is in target/wasm32-wasip1/release/hello-component-client.wasm
74+
75+
2. Build Wasm `hello` server:
7076

71-
1. Build the server Wasm component:
7277
```sh
7378
cargo build --release -p hello-component-server --target wasm32-wasip1
7479
```
80+
81+
> Output is in target/wasm32-wasip1/release/hello_component_server.wasm
7582

76-
> Output is in target/wasm32-wasip1/release/hello_component_server.wasm
77-
> NB: Rust uses `_` separators in the filename, because a component is built as a reactor-style library
83+
> NB: Rust uses `_` separators in the filename, because a component is built as a reactor-style library
7884

79-
1. Build the wRPC Wasm runtime:
85+
3. Build the wRPC Wasm runtime:
86+
8087
```sh
8188
cargo build --release --bin wrpc-wasmtime-nats
8289
```
8390

84-
> Output is in target/release/wrpc-wasmtime-nats or target/release/wrpc-wasmtime-nats.exe on Windows
91+
> Output is in target/release/wrpc-wasmtime-nats or target/release/wrpc-wasmtime-nats.exe on Windows
92+
93+
4. Run NATS (more thorough documentation available [here](https://docs.nats.io/running-a-nats-service/introduction/running)):
8594

86-
1. Run NATS (more thorough documentation available [here](https://docs.nats.io/running-a-nats-service/introduction/running)):
95+
- using standalone binary:
8796
```sh
8897
nats-server
8998
```
90-
91-
- (optional) using Docker:
99+
100+
- using Docker:
92101
```sh
93102
docker run --rm -it --name nats-server -p 4222:4222 nats:2.10.20-alpine3.20
94103
```
95104

96-
1. Serve the `hello` application using the Wasm component:
105+
5. Serve Wasm `hello` server via NATS:
106+
97107
```sh
98108
./target/release/wrpc-wasmtime-nats serve rust rust ./target/wasm32-wasip1/release/hello_component_server.wasm
99109
```
110+
111+
Sample output:
112+
> INFO async_nats: event: connected
113+
>
114+
> INFO wrpc_wasmtime_nats_cli: serving instance function name="hello"
100115

101-
Sample output:
102-
> INFO async_nats: event: connected
103-
> INFO wrpc_wasmtime_nats_cli: serving instance function name="hello"
116+
6. Call Wasm `hello` server using a Wasm `hello` client via NATS:
104117

105-
1. Call the server Wasm component from the client Wasm component:
106118
```sh
107119
./target/release/wrpc-wasmtime-nats run rust ./target/wasm32-wasip1/release/hello-component-client.wasm
108120
```
121+
122+
Sample output in the client:
123+
> INFO async_nats: event: connected
124+
>
125+
>hello from Rust
126+
127+
Sample output in the server:
128+
> INFO wrpc_wasmtime_nats_cli: serving instance function invocation headers=None
129+
>
130+
> INFO wrpc_wasmtime_nats_cli: successfully served instance function invocation
131+
132+
7. Call the Wasm `hello` server using a native wRPC `hello` client:
109133

110-
Sample output in the client:
111-
> INFO async_nats: event: connected
112-
>hello from Rust
113-
114-
Sample output in the server:
115-
> INFO wrpc_wasmtime_nats_cli: serving instance function invocation headers=None
116-
> INFO wrpc_wasmtime_nats_cli: successfully served instance function invocation
117-
118-
1. Call the server Wasm component using a native wRPC client application:
119134
```sh
120-
cargo run -p hello-nats-client
135+
cargo run -p hello-nats-client rust
121136
```
122137

123-
1. Serve the `hello` using a native wRPC server application:
138+
8. Serve native wRPC `hello` server:
139+
124140
```sh
125141
cargo run -p hello-nats-server native
126142
```
127143

128-
It can be called using either the component client or a native wRPC client
144+
9. Call both the native wRPC `hello` server and Wasm `hello` server using native wRPC `hello` client:
129145

130-
1. Call both the native wRPC `hello` server and component wRPC `hello` server using a native wRPC client application:
131146
```sh
132147
cargo run -p hello-nats-client rust native
133148
```
134149

135-
1. Call native wRPC `hello` server using the client Wasm component
150+
10. Call native wRPC `hello` server using Wasm `hello` client via NATS:
151+
136152
```sh
137153
./target/release/wrpc-wasmtime-nats run native ./target/wasm32-wasip1/release/hello-component-client.wasm
138154
```

0 commit comments

Comments
 (0)