Skip to content

Commit

Permalink
feat(*): Adds initial config interface implementation (#4)
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 <[email protected]>
  • Loading branch information
thomastaylor312 authored Jan 12, 2024
1 parent 82fc2d0 commit 7207661
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 80 deletions.
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,27 @@ A proposed [WebAssembly System Interface](https://github.com/WebAssembly/WASI) A

### Phase 4 Advancement Criteria

`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.
`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.

## Table of Contents

- [Introduction](#introduction)

### 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. Yes, that sounds generic, but applications do
all sorts of crazy things with configuration values! Calling entirely different branches of code,
setting upstream URLs or services, configuring the number of threads to use, etc.
2. toggling on/off feature flags
3. A/B testing

and many more use cases.

### TODO

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).
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).
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

## 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
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.

16 changes: 16 additions & 0 deletions wit/runtime_config.wit
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>;
}

0 comments on commit 7207661

Please sign in to comment.