A robust implementation of the Raft distributed consensus algorithm written in Go.
This project implements the core logic of the Raft state machine, designed as an asynchronous, event-driven module that can be embedded into higher-level applications (such as a distributed Key-Value store).
- Leader Election: Randomized election timeouts, RequestVote RPC handling, and role transitions (Follower -> Candidate -> Leader).
- Log Replication: AppendEntries RPCs, log matching property enforcement, and commit index advancement.
- RawNode Interface: An asynchronous boundary layer that encapsulates Raft state mutations into
Readyobjects to be processed by the host application (handling persistent storage, network message broadcasting, and state machine application). - Event-Driven Ticking: Uses a logical clock (
Tick) instead of a physical clock timer, granting the host application full control over execution timing and making it highly deterministic for testing.
This implementation was rigorously verified and tested against the comprehensive test suite provided by the PingCAP TinyKV training assignment.
The test files have been intentionally omitted from this standalone repository to maintain focus purely on the core Raft consensus logic. I would like to acknowledge and thank PingCAP for providing the excellent testing framework and scenarios that made validating this implementation possible.