Skip to content

Add: Build your own Raft (Java) - #1974

Open
naman1gupta wants to merge 1 commit into
codecrafters-io:masterfrom
naman1gupta:master
Open

Add: Build your own Raft (Java)#1974
naman1gupta wants to merge 1 commit into
codecrafters-io:masterfrom
naman1gupta:master

Conversation

@naman1gupta

Copy link
Copy Markdown

Adds one entry to Build your own Distributed Systems, which currently has a single item and no consensus implementation in any language.

Why it fits the list:

  • Built from the paper, not on a library. Plain Java 21, one runtime dependency (slf4j-api, for two debug lines). No etcd/jraft/Atomix doing the consensus.
  • Follows the paper section by section, and the README maps each mechanism to its section: terms and roles (§5.1), randomised election timeouts and RequestVote (§5.2), AppendEntries with nextIndex/matchIndex backtracking (§5.3), the up-to-date-log vote restriction (§5.4.1), and current-term-majority commit (§5.4.2).
  • Learnable by breaking it. The transport is a seam you can partition, delay and drop from a test. The headline test splits five nodes 3∥2, asserts the majority keeps committing while the minority commits nothing, heals, then asserts every node converges.
  • Scope is stated honestly. The README has a "what is deliberately not implemented" section — no log compaction, no membership changes, no linearizable reads, no pre-vote — so a reader knows where the implementation stops.
  • There is a live version to play with first: https://namangupta.me/raft-lab runs five nodes server-side and lets you kill the leader, partition the network and inject latency or loss from the browser, which is a gentler entry point than reading code cold.
  • MIT licensed, 9 passing tests, and the README code sample is itself a test so the docs cannot drift from the API.

Happy to reshape the entry text or move it if you would rather it sat elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant