nkv lets you share state between your services using client server topology. it provides you with following API:
- get the state for the given key
- put the state for the given key
- delete the state for the given key
- subscribe to the updates for the given key
- unsubscribe from the updated for the given key
Note that nkv supports keyspace, more info you can find here.
Also note that nkv clients recieve latest state and transitional states might be lost due to load. For more information reffer to this
When you have some shared state between services/processes and you also want to be notified when the value is changed
You can directly pull docker containers for client and server. They are published with each release:
Make sure that you have docker installed
when using network other than the host, the network implementation may impact network performance, unrelated to nkv itself. Also docker container builds nkv with musl, not glibc, which introduce slight perfomance degradation but gives way smaller container size, for more information refer to Design decisions doc
If you want latest version or you want to modify nkv to use different storage or notification policies, you can build and run nkv locally. In order to use it you should install Rust programming language. If you're running Linux or OSX you can do so via rustup
For Windows installation on and other methods see here
Then you can simply do following
And you'll see nkv-server and nkv-client binaries in target/release folder
Start a server by running the binary nkv-server. You can specify path to unix socket via --addr parameter, default value is /tmp/nkv/nkv.sock
You can specify log level, where to store logs and directory to store data, for more information run nkv-server --help to see available flags
Then you can use a client to access the server.
You can use the client binary nkv-client to interact with the server, or any library that supports the protocol.
To run the client binary, you can use the following commands:
Each line starts with the command, followed by the arguments. Enter the help command for a list of available commands. Each command ends with a newline character, after which the server responds.
You can specify path to UNIX socket via --addr argument, you can also run single shot commands, i.e.
depending on your shell, you might need to backslash * symbol. This could be useful if you're running nkv inside bash script.
For detailed info about design you can find here
Apart from application you can use nkv in
However, underlying design principle is that nkv is using OS primitives, making it possible to write clients in any language. Just write marshalling and demarshalling in JSON and be sure that you can connect to Server and handle Notifier. For detailed specification on components reffer to this doc
Initially, idea for such design came up in discussions with @deitch talking about improving messaging system inside EVE project called PubSub. We clearly understood one thing: serverless distributed messaging between services did was not exactly the right way to approach the problem. What we actually needed was some kind of persistent key-value storage, but with a twist: we want it to notify us when there is a change in a value. So all the clients will be able to sync over the value. Such communication mechanism would be perfect for EVE. In terms of performance the important part for us was smaller footprint and we also kept in mind that number of connections will be hundreds maximum.
.png)



