Crates.io | rust_raft |
lib.rs | rust_raft |
version | 0.1.1 |
source | src |
created_at | 2020-10-10 09:38:07.479924 |
updated_at | 2020-10-12 05:36:49.625793 |
description | A rust implementation for raft. |
homepage | https://github.com/wangmarkqi/rust_raft.git |
repository | https://github.com/wangmarkqi/rust_raft.git |
max_upload_size | |
id | 297952 |
size | 5,660,037 |
This crate is aimed to be rust raft implementation, which are a key component of many distributed systems.
This crate guarantee:
It is user responsibility to fetch data from snapshot, to save data to database, and to synchronize data which is not in the scope of current snapshot.
pub mod trans;
pub mod raft;
#[macro_use]
extern crate anyhow;
#[tokio::main]
async fn main() {
let conf = raft::raft_conf::ConfigRaft::default();
trans::server::init_app(conf);
trans::server::run_app();
raft::raft_run::cron_app().await;
}
api to process data:
append_entry: user call this funciton when add data to distribution system.
fetch_ids: use call this function to synchronize snapshot with leader. cron_app() function will call this function every ConfigRaft.update_snapshot_tick.
query_id: use id to query data from leader,user should save the data to database.It is recommended to save id in the same time to judge duplicate.