Skip to content

Commit 9b1ae92

Browse files
authored
update example configs and READMEs (#47)
Signed-off-by: markfisher <mark@modulewise.com>
1 parent 3af5c2d commit 9b1ae92

8 files changed

Lines changed: 31 additions & 52 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ config.locale = "fr-FR"
2323

2424
[component.translator]
2525
uri = "./lib/translator.wasm"
26-
imports = ["http", "io"]
26+
imports = ["http"]
2727

2828
[capability.http]
29-
uri = "wasmtime:http"
30-
31-
[capability.io]
32-
uri = "wasmtime:io"
29+
type = "wasi:http"
3330
```
3431

3532
</td>
3633
</tr></table>
3734

35+
> [!NOTE]
36+
> This project is still in an early design phase. All configurations and implementations are subject to change.
37+
3838
## Core Concepts
3939

4040
The best way to learn the core concepts of Composable Runtime is to go through the step-by-step overview in the [Sailing the 7 Cs with Composable Runtime](examples/7cs/README.md) example.

examples/7cs/README.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ $ ./run.sh 3
124124
</td>
125125
<td>
126126

127-
Host capabilities provide the interfaces a component needs to interact with the external world. For example, the `wasmtime:http` capability enables a component to make outgoing HTTP requests.
127+
Host capabilities provide the interfaces a component needs to interact with the external world. For example, the `wasi:http` capability enables a component to make outgoing HTTP requests.
128128

129129
The translator is now replaced with one that calls an external HTTP API. The `translate-api.js` implementation is slightly less simplistic as it also knows how to translate "World" into the same handful of languages.
130130

@@ -142,7 +142,7 @@ uri = "./lib/capable-translator.wasm"
142142
imports = ["http-client"]
143143

144144
[capability.http-client]
145-
uri = "wasmtime:http"
145+
type = "wasi:http"
146146
```
147147

148148
```
@@ -185,7 +185,7 @@ uri = "./lib/logging-advice.wasm"
185185
imports = ["logging-stdout"]
186186

187187
[capability.http-client]
188-
uri = "wasmtime:http"
188+
type = "wasi:http"
189189
```
190190

191191
```
@@ -240,7 +240,7 @@ uri = "./lib/logging-advice.wasm"
240240
imports = ["logging-stdout"]
241241

242242
[capability.http-client]
243-
uri = "wasmtime:http"
243+
type = "wasi:http"
244244
```
245245

246246
```
@@ -304,7 +304,7 @@ path = "/hello"
304304
channel = "names"
305305

306306
[capability.http-client]
307-
uri = "wasmtime:http"
307+
type = "wasi:http"
308308
```
309309
**ops.toml**:
310310

@@ -319,11 +319,7 @@ And finally, the shared `infra.toml` used for examples 4-7:
319319
```toml
320320
[component.logging-stdout]
321321
uri = "./lib/wasi-logging-to-stdout.wasm"
322-
imports = ["stdout", "wasip2"]
323-
324-
[capability.stdout]
325-
type = "wasi:cli"
326-
inherit-stdout = true
322+
imports = ["wasip2"]
327323

328324
[capability.wasip2]
329325
type = "wasi:p2"

examples/7cs/configs/infra.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
uri = "./lib/wasi-logging-to-stdout.wasm"
33
# could provide this here instead of the wkg pull in build.sh:
44
# uri = "oci://ghcr.io/componentized/logging/to-stdout:v0.2.1"
5-
imports = ["stdout", "wasip2"]
6-
7-
[capability.stdout]
8-
type = "wasi:cli"
9-
inherit-stdout = true
5+
imports = ["wasip2"]
106

117
[capability.wasip2]
128
type = "wasi:p2"

examples/interceptor/README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,10 @@ imports = ["stdout-logger"]
4444

4545
[component.stdout-logger]
4646
uri = "./wasi-logging-to-stdout.wasm"
47-
imports = ["stdio", "wasip2"]
48-
49-
[capability.stdio]
50-
uri = "wasmtime:inherit-stdio"
47+
imports = ["wasip2"]
5148

5249
[capability.wasip2]
53-
uri = "wasmtime:wasip2"
50+
type = "wasi:p2"
5451
```
5552

5653
## How It Works

examples/interceptor/config.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ imports = ["stdout-logger"]
1010
uri = "./wasi-logging-to-stdout.wasm"
1111
# could use this instead of pulling in the build script:
1212
# uri = "oci://ghcr.io/componentized/logging/to-stdout:v0.2.1"
13-
imports = ["stdio", "wasip2"]
14-
15-
[capability.stdio]
16-
type = "wasi:cli"
17-
inherit-stdio = true
13+
imports = ["wasip2"]
1814

1915
[capability.wasip2]
2016
type = "wasi:p2"

examples/otel/README.md

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ interface endpoint {
4141
}
4242
```
4343

44-
The endpoint is generic gRPC (OTLP-agnostic, hence the `otel-to-grpc` component). It just sends raw bytes to a named path. Path keys like `logs` and `traces` map to gRPC service paths via config, either in the `host:grpc` capability definition, or the `grpc-to-http` component definition:
44+
The endpoint is generic gRPC (OTLP-agnostic, hence the `otel-to-grpc` component). It just sends raw bytes to a named path. Path keys like `logs` and `traces` map to gRPC service paths via config, either in the `grpc` capability definition, or the `grpc-to-http` component definition:
4545

4646
```toml
47-
config.url = "http://localhost:4317"
48-
config.paths.logs = "/opentelemetry.proto.collector.logs.v1.LogsService/Export"
49-
config.paths.traces = "/opentelemetry.proto.collector.trace.v1.TraceService/Export"
47+
url = "http://localhost:4317"
48+
paths.logs = "/opentelemetry.proto.collector.logs.v1.LogsService/Export"
49+
paths.traces = "/opentelemetry.proto.collector.trace.v1.TraceService/Export"
5050
```
5151

5252
## Two Endpoint Options
@@ -67,16 +67,16 @@ uri = "./target/wasm32-wasip2/release/otel_to_grpc.wasm"
6767
imports = ["grpc", "wasip2"]
6868

6969
[capability.grpc]
70-
uri = "host:grpc"
71-
config.url = "http://localhost:4317"
72-
config.paths.logs = "/opentelemetry.proto.collector.logs.v1.LogsService/Export"
73-
config.paths.traces = "/opentelemetry.proto.collector.trace.v1.TraceService/Export"
70+
type = "grpc"
71+
url = "http://localhost:4317"
72+
paths.logs = "/opentelemetry.proto.collector.logs.v1.LogsService/Export"
73+
paths.traces = "/opentelemetry.proto.collector.trace.v1.TraceService/Export"
7474

7575
[capability.wasip2]
76-
uri = "wasmtime:wasip2"
76+
type = "wasi:p2"
7777
```
7878

79-
The "grpc" definition with `uri = "host:grpc"` creates an instance of the host capability, which the host binary has registered when building the runtime:
79+
The "grpc" definition creates an instance of the host capability, which the host binary has registered when building the runtime:
8080

8181
```rust
8282
let runtime = Runtime::builder()
@@ -105,19 +105,16 @@ imports = ["grpc", "wasip2"]
105105

106106
[component.grpc]
107107
uri = "./target/wasm32-unknown-unknown/release/grpc_to_http.wasm"
108-
imports = ["http", "io"]
108+
imports = ["http"]
109109
config.url = "http://localhost:4317"
110110
config.paths.logs = "/opentelemetry.proto.collector.logs.v1.LogsService/Export"
111111
config.paths.traces = "/opentelemetry.proto.collector.trace.v1.TraceService/Export"
112112

113113
[capability.http]
114-
uri = "wasmtime:http"
115-
116-
[capability.io]
117-
uri = "wasmtime:io"
114+
type = "wasi:http"
118115

119116
[capability.wasip2]
120-
uri = "wasmtime:wasip2"
117+
type = "wasi:p2"
121118
```
122119

123120
The `grpc-to-http` component constructs a gRPC-framed request and sends it via `wasi:http/outgoing-handler`.

examples/otel/config-with-components.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,13 @@ imports = ["grpc", "wasip2"]
88

99
[component.grpc]
1010
uri = "./target/wasm32-unknown-unknown/release/grpc_to_http.wasm"
11-
imports = ["http", "io"]
11+
imports = ["http"]
1212
config.url = "http://localhost:4317"
1313
config.paths.logs = "/opentelemetry.proto.collector.logs.v1.LogsService/Export"
1414
config.paths.traces = "/opentelemetry.proto.collector.trace.v1.TraceService/Export"
1515

1616
[capability.http]
1717
type = "wasi:http"
1818

19-
[capability.io]
20-
type = "wasi:io"
21-
2219
[capability.wasip2]
2320
type = "wasi:p2"

examples/service/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ Result: "HOWDY, World!"
3535
`GreetingService` implements `Service` with three responsibilities:
3636

3737
1. **Config handling**: A `ConfigHandler` claims the `[greeting]` category, parsing the `message` property. Config is shared with the service via `Arc<Mutex<...>>`.
38-
2. **Capability provision**: After config is parsed, `capabilities()` uses `.take()` to pull the message out of the mutex and creates a `GreetingCapability` factory. The factory also reads `uppercase` from the capability's `config.*` sub-table.
38+
2. **Capability provisioning**: After config is parsed, `capabilities()` uses `.take()` to pull the message out of the mutex and creates a `GreetingCapability` factory. The factory also reads `uppercase` from the capability's properties.
3939
3. **Lifecycle**: `start()` and `shutdown()` are called around invocation.
4040

4141
## Flow
4242

43-
1. **Configuration**: `[greeting.default]` sets `message = "Howdy"`. `[capability.greeting]` sets `config.uppercase = true`.
43+
1. **Configuration**: `[greeting.default]` sets `message = "Howdy"`. `[capability.greeting]` sets `uppercase = true`.
4444
2. **Config phase**: `GreetingConfigHandler` parses the greeting category and stores the message.
4545
3. **Capability phase**: `GreetingService.capabilities()` takes the stored message, creates a factory that applies the `uppercase` transform.
4646
4. **Invocation**: Guest calls `get_greeting()`, host returns "HOWDY", guest formats "HOWDY, World!".

0 commit comments

Comments
 (0)