A proposed WebAssembly System Interface API.
WASI Key-Value is currently in Phase 2.
wasi:keyvalue
must have at least two implementations in terms of relevant mainstream key-value
stores in each of the following categories:
The implementations must be able to run on Linux, MacOS, and Windows.
A testsuite that passes on the platforms and implementations mentioned above.
This wasi:keyvalue
proposal defines a collection of interfaces for interacting with
key-value stores. It additionally defines a world, wasi:keyvalue/imports
, that
groups together common interfaces including
There is also an additional world called wasi:keyvalue/handle-watch
, which includes the full
imports
world as well as a set of interfaces for watching for changes to a key-value store.
The API is designed to hide data-plane differences between different key-value stores. The control-plane behavior/functionality (e.g., including cluster management, data consistency, replication, and sharding) are not specified, and are provider specific.
[Interfaces]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md#wit-interfaces
The primary goal of this API is to allow WASI programs to access a wide variety of key-value stores.
This means the wasi:keyvalue
interfaces should be implementable by a wide variety of key-value
stores, including but not limited to: in-memory key-value stores, on-disk key-value stores, document
databases, relational databases, and either single-node or distributed key-value stores.
The second goal of wasi:keyvalue
interfaces is to abstract away the network stack, allowing
applications that need to access key-value stores to not worry about what network protocol is used
to access the key-value store.
A third design goal of wasi:keyvalue
interfaces is to allow performance optimizations without
compromising the portability of the API. This includes minimizing the number of copies of data,
minimizing the number of requests and round-trips, and support for asynchronous operations.
wasi:keyvalue
interfaces only focus on the most common use cases for key-value stores. It
does not attempt to cover all possible use cases.wasi:keyvalue
interfaces do not guarantee data consistency except as defined in the
interface documentation. Data consistency models (eventual, strong, casual etc.) are diverse and
are specific to each key-value store's architecture. The implication is that components importing
wasi:keyvalue
interfaces would need to be aware of the data consistency model of the key-value
store they are using.wasi:keyvalue
interfaces do not handle data replication and sharding. These are
control-plane behaviors that are specific to each key-value store's architecture. Replication
needs and sharding management are left to the outside of the wasi:keyvalue
interfaces.wasi:keyvalue
interfaces.wasi:keyvalue
interfaces.The proposal can be understood by first reading the comments of world.wit
,
store.wit
, atomic.wit
, and
batch.wit
.
Bindings can be generated from the wit
directory via:
wit-bindgen c wit/ --world imports
and can be validated and otherwise manipulated via:
wasm-tools component wit wit/ ...
This proposal was inspired by Dapr's [State API]
readwrite
and batch
interface names to eventual
and eventual-batch
. See more
details here.size
to incoming-value-size
and it's signatureget
and get-many
and keys
signatureswasi-cloud-error
to wasi-keyvalue-error
bucket
type to the types
interface.watch
operation.bulk-get
to get-multi
and bulk-set
to set-multi
to be consistent with
the naming convention of the other interfaces.