5 releases

0.1.4 Sep 15, 2024
0.1.3 Sep 15, 2024
0.1.2 Sep 14, 2024
0.1.1 Sep 14, 2024
0.1.0 Sep 14, 2024

#1590 in Algorithms

Download history 336/week @ 2024-09-13 39/week @ 2024-09-20 4/week @ 2024-09-27 1/week @ 2024-10-04

131 downloads per month

Apache-2.0

10KB
112 lines

Jarl may be Just Another Raft Library, but it makes a point to be literally just another Raft library. There's no I/O, no standard library, no dependencies, no internal allocations, no async... literally just a state machine for managing consensus of a "virtual" cell.

The library is a single Rust file. As simple as it gets.

All Raft log state is managed in-memory.

The goal is to eventually have wrapping libraries which implement various transport integrations for using "off-the-shelf" (e.g. gRPC, OpenAPI, etc.) in an actual networked context. If we're feeling cheeky, we might even implement some unexpected IPC mechanisms (Raft over SMS anyone? What about Raft over S3? Serverless Raft‽).


lib.rs:

Raft state machine

(Figure 4 from Raft paper)

Starting state = [Follower]
===========================

*******************          ┌───────────┐   **************
* Times out,      *          │           ┼──>* Times out, *
* starts election *─────────>│ Candidate │   * tries new  *
*                 *          │           │<──* election   *
*******************          └─┬───────┬─┘   **************
      ^                        v       │
 ┌────┴─────┐   *********************  │
 │ Follower │<──* Discovers current *  │
 └──────────┘   * leader or         *  │
      ^         * new term          *  │
      │         *********************  v
      │                               ******************
********************    ┌────────┐    * Receives votes *
* Discovers server *<───┼ Leader │<───* from majority  *
* with higher term *    └────────┘    * of nodes       *
********************                  ******************

No runtime deps