This is an implemenation of the hashicorp/raft Raft library. At a fundemental level this dinghy allows you to start a Raft server, that enables multiple nodes to maintain distributed consensus.
Starting the leader(first) node
./dinghy -r 7000 -h 8000 --bootstrap
Starting the other nodes
./dinghy -r 7001 -h 8001 --join="127.0.0.1:8000"
- It is important to note that if you want your nodes to have the ability of forwarding
/set
requests to the leader, you need to make the http port of your nodes 1000 greater than your raft port.
For this we will be demonstrating using curl
. All requests should be able to be made to any node given you have correctly configured your ports, but our examples will just use the address of the leader node.
Get a key
Gets the value of a given key:
curl -d '{"key": "keyname"}' -X GET http://localhost:8000/get
Set a value
Set the value of a given key:
curl -d '{"key": "keyname", "value": someinteger}' -X POST http://localhost:8000/set
Dump
Responds with the entire key-value store in JSON form:
curl -X GET http://localhost:8000/dump
Thanks to jen20 for writing the barebones implementation this is based on.