Skip to content

Commit 447470b

Browse files
committed
doc: fix formatting
Signed-off-by: Roman Volosatovs <[email protected]>
1 parent 1b15704 commit 447470b

File tree

1 file changed

+53
-36
lines changed

1 file changed

+53
-36
lines changed

README.md

Lines changed: 53 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -39,100 +39,117 @@ 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+
66+
[`wasm32-wasip2`](https://doc.rust-lang.org/nightly/rustc/platform-support/wasm32-wasip2.html) can be used instead, if desired.
67+
68+
1. Build Wasm `hello` client:
6369

64-
1. Build the client Wasm component:
6570
```sh
6671
cargo build --release -p hello-component-client --target wasm32-wasip1
6772
```
6873

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

71-
1. Build the server Wasm component:
7278
```sh
7379
cargo build --release -p hello-component-server --target wasm32-wasip1
7480
```
81+
82+
> Output is in target/wasm32-wasip1/release/hello_component_server.wasm
7583

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
84+
> NB: Rust uses `_` separators in the filename, because a component is built as a reactor-style library
7885

79-
1. Build the wRPC Wasm runtime:
86+
3. Build the wRPC Wasm runtime:
87+
8088
```sh
8189
cargo build --release --bin wrpc-wasmtime-nats
8290
```
8391

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

86-
1. Run NATS (more thorough documentation available [here](https://docs.nats.io/running-a-nats-service/introduction/running)):
96+
- using standalone binary:
8797
```sh
8898
nats-server
8999
```
90-
91-
- (optional) using Docker:
100+
101+
- using Docker:
92102
```sh
93103
docker run --rm -it --name nats-server -p 4222:4222 nats:2.10.20-alpine3.20
94104
```
95105

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

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

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

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:
119135
```sh
120-
cargo run -p hello-nats-client
136+
cargo run -p hello-nats-client rust
121137
```
122138

123-
1. Serve the `hello` using a native wRPC server application:
139+
8. Serve native wRPC `hello` server:
140+
124141
```sh
125142
cargo run -p hello-nats-server native
126143
```
127144

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

130-
1. Call both the native wRPC `hello` server and component wRPC `hello` server using a native wRPC client application:
131147
```sh
132148
cargo run -p hello-nats-client rust native
133149
```
134150

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

0 commit comments

Comments
 (0)