Lfan-ke/raft-moonbit/core does not have a README file
pub(open) trait StateMachine {
fn apply(Self, Bytes) -> Unit
}pub trait Transport {
fn request_vote(Self, String, RequestVoteArgs) -> RequestVoteReply
fn append_entries(Self, String, AppendEntriesArgs) -> AppendEntriesReply
}pub suberror ConfigError {
EmptyId
HeartbeatTickNotPositive
ElectionTickNotGreater
MaxInflightNotPositive
MaxInflightBytesTooSmall
LeaseBasedNeedsCheckQuorum
} derive(Eq)pub struct Config {
id : String
peers : Array[String]
election_tick : Int
heartbeat_tick : Int
max_msg_bytes : UInt64
max_uncommitted_size : UInt64
max_inflight : Int
max_inflight_bytes : UInt64
check_quorum : Bool
pre_vote : Bool
read_only_option : ReadOnlyOption
step_down_on_removal : Bool
disable_proposal_forwarding : Bool
disable_conf_change_validation : Bool
applied : UInt64
logger : &Logger
tracer : &Tracer
seed : UInt64
}fn Config::new(id : String, peers : Array[String], election_tick? : Int, heartbeat_tick? : Int, max_msg_bytes? : UInt64, max_uncommitted_size? : UInt64, max_inflight? : Int, max_inflight_bytes? : UInt64, check_quorum? : Bool, pre_vote? : Bool, read_only_option? : ReadOnlyOption, step_down_on_removal? : Bool, disable_proposal_forwarding? : Bool, disable_conf_change_validation? : Bool, applied? : UInt64, logger? : &Logger, tracer? : &Tracer, seed? : UInt64) -> Configpub struct DemoReport {
seed : UInt64
node_count : Int
first_leader : String?
proposal_accepted : Bool
committed : Bool
second_leader : String?
one_leader_per_term : Bool
committed_agrees : Bool
invariants_hold : Bool
}pub(all) struct FullStatus {
basic : RaftStatus
progress : Array[ProgressStatus]
config : ConfState
}type InFlightpub struct NopLogger {
}pub struct NopTracer {
}pub(all) struct ProgressStatus {
id : String
match_index : UInt64
next_index : UInt64
state : ProgressState
paused : Bool
pending_snapshot : UInt64
is_learner : Bool
} derive(Eq)pub struct RaftNode {
core : Node
id : String
peers : Array[String]
config : Membership
progress : Map[String, Progress]
votes : Map[String, Bool]
pre_vote : Bool
check_quorum : Bool
in_pre_campaign : Bool
leader_id : String?
election_elapsed : Int
heartbeat_elapsed : Int
election_timeout : Int
heartbeat_timeout : Int
randomized_election_timeout : Int
max_msg_bytes : UInt64
max_uncommitted_size : UInt64
uncommitted_size : UInt64
max_inflight : Int
max_inflight_bytes : UInt64
rng : UInt64
conf_applied : UInt64
lead_transferee : String?
read_only : ReadOnly
pending_read_index : Array[(String, Bytes)]
no_forward : Bool
pending_conf_index : UInt64
no_conf_change_validation : Bool
step_down_on_removal : Bool
pending_farewell : Array[Message]
logger : &Logger
tracer : &Tracer
}fn RaftNode::new(id : String, peers : Array[String], seed? : UInt64, election_timeout? : Int, heartbeat_timeout? : Int, max_msg_bytes? : UInt64, max_uncommitted_size? : UInt64, max_inflight? : Int, max_inflight_bytes? : UInt64, check_quorum? : Bool, pre_vote? : Bool, step_down_on_removal? : Bool, disable_conf_change_validation? : Bool, read_only_option? : ReadOnlyOption, logger? : &Logger, tracer? : &Tracer) -> RaftNodetype ReadOnlypub(all) struct StorageAppend {
entries : Array[Entry]
hard_state : HardState?
snapshot : Snapshot?
resp : StorageAppendResp
}fn demo_run(ids : Array[String], seed : UInt64, elect_ticks : Int, commit_ticks : Int, reelect_ticks : Int) -> DemoReportRaft consensus algorithm implemented in MoonBit.