Skip to content

Commit 3af5c2d

Browse files
authored
Updates to Capabilities (#44)
* changed uri to type in capability configs * renamed wasmtime capabilities to wasi * added more wasi capabilities (cli, clocks, sockets) * moved inherit/allow booleans to properties * error on unknown capability Signed-off-by: markfisher <mark@modulewise.com>
1 parent 316c7fe commit 3af5c2d

20 files changed

Lines changed: 226 additions & 147 deletions

examples/7cs/README.md

Lines changed: 10 additions & 12 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 outgoing requests, and the `wasmtime:io` capability enables the underlying streams and polling (the "io" capability is configured in a separate `infra.toml` file that is shared across examples 4-7 and shown in the final section below).
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.
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

@@ -139,7 +139,7 @@ config.locale = "fr-FR"
139139

140140
[component.translator]
141141
uri = "./lib/capable-translator.wasm"
142-
imports = ["http-client", "io"]
142+
imports = ["http-client"]
143143

144144
[capability.http-client]
145145
uri = "wasmtime:http"
@@ -177,7 +177,7 @@ config.locale = "de-DE"
177177

178178
[component.translator]
179179
uri = "./lib/capable-translator.wasm"
180-
imports = ["http-client", "io"]
180+
imports = ["http-client"]
181181
interceptors = ["logger"]
182182

183183
[component.logger]
@@ -232,7 +232,7 @@ subscription = "names"
232232

233233
[component.translator]
234234
uri = "./lib/capable-translator.wasm"
235-
imports = ["http-client", "io"]
235+
imports = ["http-client"]
236236
interceptors = ["logger"]
237237

238238
[component.logger]
@@ -288,7 +288,7 @@ subscription = "names"
288288

289289
[component.translator]
290290
uri = "./lib/capable-translator.wasm"
291-
imports = ["http-client", "io"]
291+
imports = ["http-client"]
292292
interceptors = ["logger"]
293293
```
294294

@@ -319,16 +319,14 @@ 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 = ["stdio", "wasip2"]
322+
imports = ["stdout", "wasip2"]
323323

324-
[capability.io]
325-
uri = "wasmtime:io"
326-
327-
[capability.stdio]
328-
uri = "wasmtime:inherit-stdio"
324+
[capability.stdout]
325+
type = "wasi:cli"
326+
inherit-stdout = true
329327

330328
[capability.wasip2]
331-
uri = "wasmtime:wasip2"
329+
type = "wasi:p2"
332330
```
333331

334332
```

examples/7cs/configs/4-capability.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ config.locale = "fr-FR"
55

66
[component.translator]
77
uri = "./lib/capable-translator.wasm"
8-
imports = ["http-client", "io"]
8+
imports = ["http-client"]
99

1010
[capability.http-client]
11-
uri = "wasmtime:http"
11+
type = "wasi:http"

examples/7cs/configs/5-cross-cutting-concerns.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ config.locale = "de-DE"
55

66
[component.translator]
77
uri = "./lib/capable-translator.wasm"
8-
imports = ["http-client", "io"]
8+
imports = ["http-client"]
99
interceptors = ["logger"]
1010

1111
[component.logger]
1212
uri = "./lib/logging-advice.wasm"
1313
imports = ["logging-stdout"]
1414

1515
[capability.http-client]
16-
uri = "wasmtime:http"
16+
type = "wasi:http"

examples/7cs/configs/6-channel.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ subscription = "names"
1414

1515
[component.translator]
1616
uri = "./lib/capable-translator.wasm"
17-
imports = ["http-client", "io"]
17+
imports = ["http-client"]
1818
interceptors = ["logger"]
1919

2020
[component.logger]
2121
uri = "./lib/logging-advice.wasm"
2222
imports = ["logging-stdout"]
2323

2424
[capability.http-client]
25-
uri = "wasmtime:http"
25+
type = "wasi:http"

examples/7cs/configs/7-collaboration-domain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ subscription = "names"
66

77
[component.translator]
88
uri = "./lib/capable-translator.wasm"
9-
imports = ["http-client", "io"]
9+
imports = ["http-client"]
1010
interceptors = ["logger"]

examples/7cs/configs/7-collaboration-env.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ path = "/hello"
77
channel = "names"
88

99
[capability.http-client]
10-
uri = "wasmtime:http"
10+
type = "wasi:http"

examples/7cs/configs/infra.toml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
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 = ["stdio", "wasip2"]
5+
imports = ["stdout", "wasip2"]
66

7-
[capability.io]
8-
uri = "wasmtime:io"
9-
10-
[capability.stdio]
11-
uri = "wasmtime:inherit-stdio"
7+
[capability.stdout]
8+
type = "wasi:cli"
9+
inherit-stdout = true
1210

1311
[capability.wasip2]
14-
uri = "wasmtime:wasip2"
12+
type = "wasi:p2"

examples/host-capability/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[capability.greeting]
2-
uri = "host:greeting"
2+
type = "greeting"
33

44
[component.greeter]
55
uri = "./target/wasm32-unknown-unknown/release/greeter.wasm"

examples/interceptor/config.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ uri = "./wasi-logging-to-stdout.wasm"
1313
imports = ["stdio", "wasip2"]
1414

1515
[capability.stdio]
16-
uri = "wasmtime:inherit-stdio"
16+
type = "wasi:cli"
17+
inherit-stdio = true
1718

1819
[capability.wasip2]
19-
uri = "wasmtime:wasip2"
20+
type = "wasi:p2"

examples/otel/config-with-components.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ 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]
17-
uri = "wasmtime:http"
17+
type = "wasi:http"
1818

1919
[capability.io]
20-
uri = "wasmtime:io"
20+
type = "wasi:io"
2121

2222
[capability.wasip2]
23-
uri = "wasmtime:wasip2"
23+
type = "wasi:p2"

0 commit comments

Comments
 (0)