kvstore is a simple key-value store based on etcd's raft library. It provides a simple REST API for a key-value store cluster backed by the Raft consensus algorithm.
go build -o kvstore
First start a single-member cluster of kvstore:
./kvstore --id 1 --cluster http://127.0.0.1:12379 --port 12380
Each kvstore process is a key-value service.
The process's list of comma separated peers (--cluster), it's raft ID index into the peer list (--id), and http key-value service port (--port) are passed through the command line.
Next, store a value ("hello") to a key ("my-key"):
curl -L http://127.0.0.1:12380/my-key -XPUT -d hello
Finally, retrieve the stored key:
curl -L http://127.0.0.1:12380/my-key
First install goreman, which manages Procfile-based applications.
The Procfile script will set up a local cluster. Start it with:
goreman start
This will bring up three instances.
Now it's possible to write a key-value pair to any member of the cluster and likewise retrieve it from any member.
TODO
The kvstore consists of three components:
- a REST API service
- a raft consensus service based on etcd's raft implementation.
- a simple map as a RSM