#raft

lol-core

A Raft implementation in Rust language

19 releases (6 breaking)

0.7.2 Apr 1, 2021
0.7.1 Feb 2, 2021
0.7.0 Jan 25, 2021
0.6.2 Dec 10, 2020
0.5.3 Nov 30, 2020

#398 in Algorithms

Download history 43/week @ 2021-04-02 9/week @ 2021-04-09 83/week @ 2021-04-16 8/week @ 2021-04-23 25/week @ 2021-04-30 19/week @ 2021-05-14 19/week @ 2021-06-11 2/week @ 2021-07-02 21/week @ 2021-07-16

181 downloads per month

MIT license

125KB
3K SLoC

lol

Crates.io documentation CI MIT licensed Tokei

A Raft implementation in Rust language. To support this project please give it a ⭐

Documentation (mdBook)

Features

  • Implements all basic Raft features: Replication, Leader Election, Log Compaction, Persistency, Dynamic Membership Change, Streaming Snapshot, etc.
  • Based on Tonic and efficient gRPC streaming is fully utilized in log replication and snapshot copying.
  • Phi Accrual Failure Detector is used in leader failure detection. This adaptive algorithm lets you not choose a fixed timeout number before deployment and makes it possible to deploy Raft node in Geo-distributed environment. This algorithm is also used in Akka.
  • Clear Abstractions: RaftApp is your application or state machine in Raft's context. RaftStorage is the abstraction of the backend storage with which both in-memory and persistent (backed by RocksDB) are supported.

Example

// Implement RaftApp for YourApp!
struct YourApp { ... }
impl RaftApp for YourApp {
    ...
}
let app = YourApp { ... };
let storage = ...; // Choose a backend from lol_core::storage
let core = RaftCore::new(app, storage, config, ...);
let service = lol_core::make_service(core);
tonic::transport::Server::builder()
    .add_service(service)
    .serve(socket).await;

Related Projects

Development

Use docker container to make an dev environment on your computer.

  • make docker-build to build the docker image
  • ./dev to start the container

then

  • cargo build to compile the whole project
  • make test to run the regression tests
  • make bench to run the benchmark

Dependencies

~6–12MB
~209K SLoC