A minimal implementation of Raft in Go.
NOT FOR PRODUCTION USE.
Things that are missing:
- A half-decent persistence plan
- Snapshotting/checkpointing and associated state transfer
- Configuration change protocol
- Rigged up to Jepsen
- Surely much else
Not particularly aggressive yet but does some minimal testing.
$ cd cmd/sim
$ go run main.go
Try out the builtin distributed key-value API.
$ cd cmd/kvapi && go build
$ rm *.dat
$ ./kvapi --node 1 --http :2021 --cluster "0,:3030;1,:3031;2,:3032"
$ ./kvapi --node 1 --http :2021 --cluster "0,:3030;1,:3031;2,:3032"
$ ./kvapi --node 2 --http :2021 --cluster "0,:3030;1,:3031;2,:3032"
To set a key:
$ curl -v http://localhost:2020/set -d '{"key": "y", "value": "hello"}' -X POST
To get a key:
$ curl -v http://localhost:2021/get\?key\=y
- In Search of an Understandable Consensus Algorithm: The Raft paper.
- raft.tla: Diego Ongaro's TLA spec for Raft.
- Jon Gjengset's Students' Guide to Raft
- Jack Vanlightly's Detecting Bugs in Data Infrastructure using Formal Methods (TLA Series Part 1): An intro to TLA .
Other useful implementations to peer at:
- Hashicorp's Raft implementation in Go: Although it's often quite complicated to learn from since it actually is intended for production.
- Eli Bendersky's Raft implementation in Go: Although it gets confusing because it uses negative numbers for terms whereas the paper does not.
- Jing Yang's Raft implementation in Rust.