Skip to content

Commit 7207661

Browse files
feat(*): Adds initial config interface implementation (#4)
This is the most basic functionality needed to have a shared config interface that all components could use. It's goal is simplicity. There are many things we could add/polish, and all of those are called out in the documentation. For reference, this is what we are using in wasmCloud, but we aren't married to the interface as is. What we want is the ability for any runtime to be able to provide configuration to the components it is running in a standardized way. That will make it possible to actually have the cross runtime/platform experience that components promise Signed-off-by: Taylor Thomas <[email protected]>
1 parent 82fc2d0 commit 7207661

File tree

6 files changed

+68
-80
lines changed

6 files changed

+68
-80
lines changed

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,27 @@ A proposed [WebAssembly System Interface](https://github.com/WebAssembly/WASI) A
1414

1515
### Phase 4 Advancement Criteria
1616

17-
`wasi-runtime-config` should have at least two implementations (i.e., from service providers, and or cloud providers), and, at the very minimum, pass the testsuite for Windows, Linux, and MacOS.
17+
`wasi-runtime-config` should have at least two implementations (i.e., from service providers, and or
18+
cloud providers), and, at the very minimum, pass the testsuite for Windows, Linux, and MacOS.
1819

1920
## Table of Contents
2021

2122
- [Introduction](#introduction)
2223

2324
### Introduction
2425

25-
The `wasi-runtime-config` world aim to provide a set of generic interfaces for dynamic configuration management systems. They are often the source of the configuration truth that lives in external services. Configuration values are often polled by the application for
26+
The `wasi-runtime-config` world aim to provide a set of generic interfaces for providing
27+
configuration to a component. Configuration values are often polled by the application for
2628

27-
1. toggling on/off feature flags
28-
2. A/B testing
29-
3. reading user allow/deny lists
29+
1. Configuring the runtime behavior of a component. Yes, that sounds generic, but applications do
30+
all sorts of crazy things with configuration values! Calling entirely different branches of code,
31+
setting upstream URLs or services, configuring the number of threads to use, etc.
32+
2. toggling on/off feature flags
33+
3. A/B testing
3034

3135
and many more use cases.
3236

3337
### TODO
3438

35-
This readme needs to be expanded to cover a number of additional fields suggested in the [WASI Proposal template](https://github.com/WebAssembly/wasi-proposal-template).
39+
This readme needs to be expanded to cover a number of additional fields suggested in the [WASI
40+
Proposal template](https://github.com/WebAssembly/wasi-proposal-template).

config.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Runtime Config API
2+
3+
## Runtime Types
4+
5+
### `variant config-error`
6+
7+
An error type that encapsulates the different errors that can occur fetching config:
8+
9+
- `upstream(string)`: This indicates an error from an "upstream" config source. As this could be almost _anything_ (such as Vault, Kubernetes ConfigMaps, KeyValue buckets, etc), the error message is a string.
10+
- `io(string)`: This indicates an error from an I/O operation. As this could be almost _anything_ (such as a file read, network connection, etc), the error message is a string. Depending on how this ends up being consumed, we may consider moving this to use the `wasi:io/error` type instead. For simplicity right now in supporting multiple implementations, it is being left as a string.
11+
12+
13+
## Runtime Functions
14+
15+
## `get`
16+
17+
Gets a single opaque config value set at the given key if it exists
18+
19+
**Params:**
20+
21+
- `key`: A string key to fetch
22+
23+
**Returns:**
24+
25+
`result<option<list<u8>>, config-error>`
26+
27+
An opaque value if the key exists, otherwise `none`
28+
29+
## `get-all`
30+
31+
Gets all available configuration values
32+
33+
**Params:**
34+
35+
None
36+
37+
**Returns:**
38+
39+
`result<list<tuple<string, list<u8>>>, config-error>`
40+
41+
A list of key/value tuples

proposal-template.abi.md

Lines changed: 0 additions & 31 deletions
This file was deleted.

proposal-template.wit.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

test/README.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

wit/runtime_config.wit

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package wasi:config@0.1.0;
2+
3+
interface runtime {
4+
/// Errors that can be returned from config sources
5+
variant config-error {
6+
/// An error occurred on the config source when fetching data
7+
upstream(string),
8+
/// I/O or connection failure when fetching data
9+
io(string),
10+
};
11+
12+
/// Gets a single opaque config value set at the given key if it exists
13+
get: func(key: string) -> result<option<list<u8>>, config-error>;
14+
/// Gets a list of all set config data
15+
get-all: func() -> result<list<tuple<string, list<u8>>>, config-error>;
16+
}

0 commit comments

Comments
 (0)