generated from WebAssembly/wasi-proposal-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]>
- Loading branch information
1 parent
82fc2d0
commit 7207661
Showing
6 changed files
with
68 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Runtime Config API | ||
|
||
## Runtime Types | ||
|
||
### `variant config-error` | ||
|
||
An error type that encapsulates the different errors that can occur fetching config: | ||
|
||
- `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. | ||
- `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. | ||
|
||
|
||
## Runtime Functions | ||
|
||
## `get` | ||
|
||
Gets a single opaque config value set at the given key if it exists | ||
|
||
**Params:** | ||
|
||
- `key`: A string key to fetch | ||
|
||
**Returns:** | ||
|
||
`result<option<list<u8>>, config-error>` | ||
|
||
An opaque value if the key exists, otherwise `none` | ||
|
||
## `get-all` | ||
|
||
Gets all available configuration values | ||
|
||
**Params:** | ||
|
||
None | ||
|
||
**Returns:** | ||
|
||
`result<list<tuple<string, list<u8>>>, config-error>` | ||
|
||
A list of key/value tuples |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package wasi:config@0.1.0; | ||
|
||
interface runtime { | ||
/// Errors that can be returned from config sources | ||
variant config-error { | ||
/// An error occurred on the config source when fetching data | ||
upstream(string), | ||
/// I/O or connection failure when fetching data | ||
io(string), | ||
}; | ||
|
||
/// Gets a single opaque config value set at the given key if it exists | ||
get: func(key: string) -> result<option<list<u8>>, config-error>; | ||
/// Gets a list of all set config data | ||
get-all: func() -> result<list<tuple<string, list<u8>>>, config-error>; | ||
} |