Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

riteraft

> 编程语言
Open source

RiteRaft - A raft framework, for regular people

332 stars0 likes1 views
WebsiteGitHub

About

RiteRaft - A raft framework, for regular people

RiteRaft - A raft framework, for regular people

This is an attempt to create a layer on top of tikv/raft-rs, that is easier to use and implement. This is not supposed to be the most featureful raft, but instead a convenient interface to get started quickly, and have a working raft in no time.

The interface is strongly inspired by the one used by canonical/raft.

Getting started

In order to "raft" storage, we need to implement the Storage trait for it. Bellow is an example with HashStore, which is a thread-safe wrapper around an HashMap:

…

Only 3 methods need to be implemented for the Store:

  • Store::apply: applies a commited entry to the store.
  • Store::snapshot: returns snapshot data for the store.
  • Store::restore: applies the snapshot passed as argument.

running the raft

rust
#[tokio::main]
fn main() {
    let store = HashStore::new();

    let raft = Raft::new(options.raft_addr, store.clone());
    let mailbox = Arc::new(raft.mailbox());
    let (raft_handle, mailbox) = match options.peer_addr {
        Some(addr) => {
            info!("running in follower mode");
            let handle = tokio::spawn(raft.join(addr));
            (handle, mailbox)
        }
        None => {
            info!("running in leader mode");
            let handle =  tokio::spawn(raft.lead());
            (handle, mailbox)
        }
    };

    tokio::join!(raft);
}

The mailbox gives you a way to interact with the raft, for sending a message, or leaving the cluster for example.

Credit

This work is based on raft-frp, but more adjustments and improvements have been made to the code .

License

This library is licensed under either of:

  • MIT license LICENSE-MIT or http://opensource.org/licenses/MIT
  • Apache License 2.0 LICENSE-APACHE or https://opensource.org/licenses/Apache-2.0

at your option.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rustdistributeddistributed-systemsraftraft-framework

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言