Skip to content

Commit

Permalink
feat(*): Adds initial config interface implementation
Browse files Browse the repository at this point in the history
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 <taylor@cosmonic.com>
  • Loading branch information
thomastaylor312 committed Nov 22, 2023
1 parent 82fc2d0 commit 09092fa
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 78 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ A proposed [WebAssembly System Interface](https://github.com/WebAssembly/WASI) A

### Introduction

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
The `wasi-runtime-config` world aim to provide a set of generic interfaces for providing configuration to a component. Configuration values are often polled by the application for

1. toggling on/off feature flags
2. A/B testing
3. reading user allow/deny lists
1. Configuring the runtime behavior of a component
2. toggling on/off feature flags
3. A/B testing

and many more use cases.

Expand Down
41 changes: 41 additions & 0 deletions config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Runtime Config API

## 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 Config 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
31 changes: 0 additions & 31 deletions proposal-template.abi.md

This file was deleted.

32 changes: 0 additions & 32 deletions proposal-template.wit.md

This file was deleted.

11 changes: 0 additions & 11 deletions test/README.md

This file was deleted.

10 changes: 10 additions & 0 deletions wit/runtime_config.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package wasi:config@0.1.0;

interface runtime-config {
use types.{config-error};

/// 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>;
}
11 changes: 11 additions & 0 deletions wit/types.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package wasi:config@0.1.0;

interface types {
/// 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),
};
}
5 changes: 5 additions & 0 deletions wit/world.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package wasi:config@0.1.0;

world config {
import runtime-config;
}

0 comments on commit 09092fa

Please sign in to comment.