~/raft-moonbit

Reference

The public API

Generated straight from pkg.generated.mbti — the interface moon info emits and the 723-test suite pins. 58 types · 300 methods · 30 free functions.

Start with RaftNode (message-driven) or Cluster (the batteries-included simulator). RawNode is the Ready/Advance driver a real deployment runs.

Functions & constants

Synchronous drivers · 5
  • committed_index(Array[String], Array[String], Map[String, UInt64]) UInt64
  • vote_result(Array[String], Array[String], Map[String, Bool]) VoteState
  • replicate(Node, Array[Node]) UInt64
  • run_election(Node, Array[Node]) Bool
  • run_single_node(String, Array[Bytes]) Array[Bytes]
Log & entry helpers · 14
  • describe(Array[String], Map[String, UInt64]) String
  • entry_encoding_size(Entry) UInt64
  • ents_size(ArrayView[Entry]) UInt64
  • hard_state_equal(HardState, HardState) Bool
  • limit_size(ArrayView[Entry], UInt64) Array[Entry]
  • no_limit : UInt64
  • payload_size(Entry) UInt64
  • payloads_size(ArrayView[Entry]) UInt64
  • describe_conf_state(@raftpb.ConfState) String
  • describe_entries(ArrayView[@raftpb.Entry], ((Bytes) -> String)?) String
  • describe_entry(@raftpb.Entry, ((Bytes) -> String)?) String
  • describe_hard_state(@raftpb.HardState) String
  • describe_snapshot(@raftpb.Snapshot) String
  • must_sync(@raftpb.HardState, @raftpb.HardState, Int) Bool
Browser-demo bridge (FFI) · 11
  • demo_report_lines(DemoReport) Array[String]
  • demo_run(Array[String], UInt64, Int, Int, Int) DemoReport
  • wnode_campaign() Unit
  • wnode_drain() String
  • wnode_new(Int, Int, Int) Unit
  • wnode_propose(Int) Unit
  • wnode_recv_apply() Unit
  • wnode_recv_push(Int) Unit
  • wnode_recv_reset() Unit
  • wnode_state() String
  • wnode_tick() Unit

RaftNode

struct

The message-driven consensus server: timers, campaigns, and the tick / step surface a transport drives.

Fields
  • core : Node
  • id : String
  • peers : Array[String]
  • config : @confchange.Membership
  • progress : Map[String, @tracker.Progress]
  • votes : Map[String, Bool]
  • mut pre_vote : Bool
  • mut check_quorum : Bool
  • mut in_pre_campaign : Bool
  • mut leader_id : String?
  • mut election_elapsed : Int
  • mut heartbeat_elapsed : Int
  • election_timeout : Int
  • heartbeat_timeout : Int
  • mut randomized_election_timeout : Int
  • max_msg_bytes : UInt64
  • max_uncommitted_size : UInt64
  • mut uncommitted_size : UInt64
  • max_inflight : Int
  • max_inflight_bytes : UInt64
  • mut rng : UInt64
  • mut conf_applied : UInt64
  • mut lead_transferee : String?
  • read_only : ReadOnly
  • pending_read_index : Array[(String, Bytes)]
  • mut no_forward : Bool
  • mut pending_conf_index : UInt64
  • no_conf_change_validation : Bool
  • step_down_on_removal : Bool
  • pending_farewell : Array[@raftpb.Message]
  • logger : &Logger
  • tracer : &Tracer
Methods · 50
  • advance_applied(Self, UInt64) Unit
  • become_candidate(Self) Unit
  • become_follower(Self, UInt64) Unit
  • campaign(Self) Array[@raftpb.Message]
  • commit_index(Self) UInt64
  • conf_state(Self) @raftpb.ConfState
  • disable_proposal_forwarding(Self) Unit
  • election_deadline(Self) Int
  • enable_check_quorum(Self) Unit
  • enable_read_only_safe(Self) Unit
  • forget_leader(Self) Unit
  • from_config(Config) Self raise ConfigError
  • full_status(Self) FullStatus
  • has_lease(Self) Bool
  • id(Self) String
  • is_leader(Self) Bool
  • leader(Self) String?
  • new(String, 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) Self
  • node(Self) Node
  • progress_of(Self, String) ProgressStatus?
  • progress_status(Self) Array[ProgressStatus]
  • promotable(Self) Bool
  • propose(Self, Bytes) Array[@raftpb.Message]
  • propose_conf(Self, @confchange.ConfChange) Array[@raftpb.Message]
  • propose_conf_v2(Self, @confchange.ConfChangeV2) Array[@raftpb.Message]
  • quorum_active(Self) Bool
  • raw(Self) RawNode
  • raw_async(Self) RawNode
  • raw_async_sized(Self, UInt64) RawNode
  • raw_with_max_committed_size(Self, UInt64) RawNode
  • read_index(Self) UInt64?
  • read_only_option(Self) ReadOnlyOption
  • reduce_uncommitted_size(Self, UInt64) Unit
  • report_snapshot(Self, String, Bool) Unit
  • report_unreachable(Self, String) Unit
  • request_read_index(Self, Bytes) Array[@raftpb.Message]
  • request_transfer_leader(Self, String) Array[@raftpb.Message]
  • role(Self) Role
  • set_pre_vote(Self, Bool) Unit
  • set_read_only_option(Self, ReadOnlyOption) Unit
  • soft_state(Self) SoftState
  • status(Self) RaftStatus
  • step(Self, @raftpb.Message) Array[@raftpb.Message]
  • take_read_states(Self) Array[ReadState]
  • term(Self) UInt64
  • tick(Self) Array[@raftpb.Message]
  • transfer_leadership(Self, String) Array[@raftpb.Message]
  • uncommitted_size(Self) UInt64
  • voter_nodes(Self) Array[String]
  • with_progress(Self, (String, ProgressStatus) -> Unit) Unit

RawNode

struct

The synchronous Ready/Advance driver over a RaftNode — the batch a real deployment persists, sends, and applies.

Fields
  • raft : RaftNode
  • mut log : @log.RaftLog
  • max_committed : UInt64
  • msgs : Array[@raftpb.Message]
  • read_states : Array[ReadState]
  • mut prev_soft : SoftState
  • mut prev_hard : @raftpb.HardState
  • mut async_storage : Bool
  • mut reflected_snap : UInt64
Methods · 30
  • advance(Self, Ready) Unit
  • apply_conf_change(Self, @confchange.ConfChange) Array[String]
  • basic_status(Self) RaftStatus
  • campaign(Self) Unit
  • conf_state(Self) @raftpb.ConfState
  • forget_leader(Self) Unit
  • full_status(Self) FullStatus
  • has_ready(Self) Bool
  • is_async(Self) Bool
  • new(RaftNode) Self
  • new_sized(RaftNode, UInt64) Self
  • next_unstable_snapshot(Self) @raftpb.Snapshot?
  • node(Self) RaftNode
  • propose(Self, Bytes) Unit
  • propose_conf(Self, @confchange.ConfChange) Unit
  • propose_conf_v2(Self, @confchange.ConfChangeV2) Unit
  • read_index(Self, Bytes) Unit
  • ready(Self) Ready
  • ready_without_accept(Self) Ready
  • report_snapshot(Self, String, Bool) Unit
  • report_unreachable(Self, String) Unit
  • stabilize(Self) Array[@raftpb.Message]
  • status(Self) RaftStatus
  • step(Self, @raftpb.Message) Unit
  • step_append_resp(Self, StorageAppendResp) Unit
  • step_apply_resp(Self, StorageApplyResp) Unit
  • store(Self, Ready) Unit
  • tick(Self) Unit
  • transfer_leader(Self, String) Unit
  • with_progress(Self, (String, ProgressStatus) -> Unit) Unit

Ready

struct

One batch of outstanding work: state changes, entries to persist, committed entries to apply, and messages to send.

Fields
  • soft_state : SoftState?
  • hard_state : @raftpb.HardState?
  • read_states : Array[ReadState]
  • entries : Array[@raftpb.Entry]
  • snapshot : @raftpb.Snapshot?
  • committed_entries : Array[@raftpb.Entry]
  • messages : Array[@raftpb.Message]
  • must_sync : Bool
  • storage_append : StorageAppend?
  • storage_apply : StorageApply?

Message

struct

A routed message — a sender, a recipient, and a Payload. The unit a transport moves without interpreting.

Fields
  • from : String
  • to : String
  • payload : Payload
  • force : Bool
Methods · 4
  • is_response(Self) Bool
  • kind(Self) String
  • new(String, String, Payload, force? : Bool) Self
  • term(Self) UInt64

Cluster

struct

The deterministic, single-seed simulator: drop, delay, reorder, partition, crash — with safety-invariant checks.

Fields
  • nodes : Map[String, RaftNode]
  • ids : Array[String]
  • mut inflight : Array[InFlight]
  • mut now : Int
  • part : Map[String, Int]
  • down : Map[String, Bool]
  • mut drop_permil : Int
  • mut max_delay : Int
  • mut next_group : Int
  • mut rng : UInt64
Methods · 28
  • all_committed(Self, UInt64) Bool
  • committed_agrees(Self) Bool
  • compact_leader(Self, UInt64, Bytes) Bool
  • crash(Self, String) Unit
  • enable_check_quorum(Self) Unit
  • heal(Self) Unit
  • invariants_hold(Self) Bool
  • is_down(Self, String) Bool
  • isolate(Self, String) Unit
  • leader(Self) String?
  • leaders(Self) Array[String]
  • logs_consistent(Self) Bool
  • new(Array[String], seed? : UInt64) Self
  • node(Self, String) RaftNode
  • one_leader_per_term(Self) Bool
  • partition(Self, Array[String], Array[String]) Unit
  • propose(Self, Bytes) Bool
  • propose_conf(Self, @confchange.ConfChange) Bool
  • propose_on(Self, String, Bytes) Bool
  • restart(Self, String) Unit
  • run(Self, Int) Unit
  • run_until_committed(Self, UInt64, Int) Bool
  • run_until_leader(Self, Int) String?
  • same_committed_commands(Self) Bool
  • set_delay(Self, Int) Unit
  • set_drop(Self, Int) Unit
  • tick(Self) Unit
  • transfer_leadership(Self, String) Bool

Node

struct

The consensus core state and role transitions the RaftNode wraps.

Fields
  • id : String
  • mut role : Role
  • mut current_term : UInt64
  • mut voted_for : String?
  • log : Array[@raftpb.Entry]
  • mut commit_index : UInt64
  • mut last_applied : UInt64
  • mut snapshot_index : UInt64
  • mut snapshot_term : UInt64
Methods · 36
  • advance_commit(Self, UInt64) Unit
  • append(Self, UInt64, Bytes) @raftpb.Entry
  • append_conf(Self, UInt64, Bytes) @raftpb.Entry
  • apply_committed(Self, &StateMachine) Unit
  • apply_hard_state(Self, @raftpb.HardState) Unit
  • become_candidate(Self) Unit
  • become_follower(Self, UInt64) Unit
  • become_leader(Self) Unit
  • become_pre_candidate(Self) Unit
  • compact(Self, UInt64, Bytes, conf_state? : @raftpb.ConfState) @raftpb.Snapshot
  • current_term(Self) UInt64
  • entries_after(Self, UInt64) Array[@raftpb.Entry]
  • entries_after_limited(Self, UInt64, UInt64) Array[@raftpb.Entry]
  • entry_at(Self, UInt64) @raftpb.Entry?
  • find_conflict_by_term(Self, UInt64, UInt64) (UInt64, UInt64)
  • handle_append_entries(Self, @raftpb.AppendEntriesArgs) @raftpb.AppendEntriesReply
  • handle_install_snapshot(Self, @raftpb.InstallSnapshotArgs) @raftpb.InstallSnapshotReply
  • handle_request_vote(Self, @raftpb.RequestVoteArgs) @raftpb.RequestVoteReply
  • hard_state(Self) @raftpb.HardState
  • install_snapshot(Self, @raftpb.Snapshot) Unit
  • last_log_index(Self) UInt64
  • last_log_term(Self) UInt64
  • load_from(Self, &@storage.RaftStorage) Unit
  • log_len(Self) Int
  • mark_applied(Self, UInt64) Unit
  • new(String) Self
  • persisted(Self) @storage.Persisted
  • propose_conf_change(Self, UInt64, @confchange.ConfChange) @raftpb.Entry
  • recover(Self, @storage.Persisted) Unit
  • recover_from(Self, &@storage.WalStore) Unit
  • replay(Self, Array[@storage.WalRecord]) Unit
  • request_vote_args(Self) @raftpb.RequestVoteArgs
  • role(Self) Role
  • save_into(Self, @storage.MemoryStorage) Unit
  • save_to(Self, &@storage.WalStore) Unit
  • term_at(Self, UInt64) UInt64

RaftStatus

structderive(Eq)

A point-in-time snapshot of a server's observable state, for monitoring and tests.

Fields
  • id : String
  • role : Role
  • term : UInt64
  • leader : String?
  • commit : UInt64
  • last_index : UInt64
  • applied : UInt64
Methods · 1
  • describe(Self) String

AppendEntriesArgs

structderive(Eq)
Fields
  • term : UInt64
  • leader_id : String
  • prev_log_index : UInt64
  • prev_log_term : UInt64
  • entries : Array[Entry]
  • leader_commit : UInt64

AppendEntriesReply

structderive(Eq)
Fields
  • term : UInt64
  • success : Bool
  • match_index : UInt64
  • conflict_index : UInt64
  • conflict_term : UInt64
  • reject_index : UInt64

Changer

struct
Fields
  • mut cfg : ChangerConfig
  • mut prs : Map[String, @tracker.Progress]
  • mut last_index : UInt64
  • max_inflight : Int
  • max_inflight_bytes : UInt64
Methods · 8
  • advance_index(Self) Unit
  • conf_state(Self) @raftpb.ConfState
  • describe(Self) String
  • enter_joint(Self, Bool, Array[(String, String)]) String?
  • leave_joint(Self) String?
  • new(last_index? : UInt64, max_inflight? : Int, max_inflight_bytes? : UInt64) Self
  • restore(Self, @raftpb.ConfState) String?
  • simple(Self, Array[(String, String)]) String?

ChangerConfig

struct
Fields
  • incoming : Array[String]
  • outgoing : Array[String]
  • learners : Array[String]
  • learners_next : Array[String]
  • mut auto_leave : Bool

ConfChange

structderive(Eq)
Fields
  • change_type : ConfChangeType
  • node_id : String
Methods · 6
  • add(String) Self
  • add_learner(String) Self
  • apply_to(Self, Membership) Unit
  • decode(Bytes) Self?
  • encode(Self) Bytes
  • remove(String) Self

ConfChangeTransition

enumderive(Eq)
Variants
  • Auto
  • JointImplicit
  • JointExplicit

ConfChangeType

enumderive(Eq)
Variants
  • AddNode
  • RemoveNode
  • AddLearnerNode

ConfChangeV2

structderive(Eq)
Fields
  • changes : Array[ConfChange]
  • transition : ConfChangeTransition
Methods · 8
  • auto(Array[ConfChange]) Self
  • auto_leave(Self) Bool
  • decode(Bytes) Self?
  • encode(Self) Bytes
  • enter_joint(Array[ConfChange], auto_leave? : Bool) Self
  • enters_joint(Self) (Bool, Bool)
  • is_leave(Self) Bool
  • leave_joint() Self

ConfDriver

struct
Fields
  • config : @confchange.Membership
  • mut applied : UInt64
Methods · 3
  • config(Self) @confchange.Membership
  • drive(Self, Node) Int
  • new(Array[String]) Self

ConfState

structderive(Eq)
Fields
  • voters : Array[String]
  • learners : Array[String]
  • voters_outgoing : Array[String]
  • learners_next : Array[String]
  • auto_leave : Bool
Methods · 3
  • empty() Self
  • equivalent(Self, Self) Bool
  • is_empty(Self) Bool

Config

struct
Fields
  • 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
Methods · 2
  • new(String, 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) Self
  • validate(Self) Unit raise ConfigError

DemoReport

struct
Fields
  • 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

Entry

structderive(Eq)
Fields
  • term : UInt64
  • index : UInt64
  • entry_type : EntryType
  • command : Bytes
Methods · 4
  • conf(UInt64, UInt64, Bytes) Self
  • id(Self) EntryId
  • is_conf_change(Self) Bool
  • normal(UInt64, UInt64, Bytes) Self

EntryId

structderive(Eq)
Fields
  • term : UInt64
  • index : UInt64

EntryType

enumderive(Eq)
Variants
  • Normal
  • ConfChange

FullStatus

struct
Fields
  • basic : RaftStatus
  • progress : Array[ProgressStatus]
  • config : @raftpb.ConfState

HardState

structderive(Eq)
Fields
  • term : UInt64
  • vote : String?
  • commit : UInt64
Methods · 2
  • initial() Self
  • is_empty(Self) Bool

HeartbeatArgs

structderive(Eq)
Fields
  • term : UInt64
  • leader_id : String
  • commit : UInt64
  • context : Bytes

HeartbeatReply

structderive(Eq)
Fields
  • term : UInt64
  • context : Bytes

Inflight

structderive(Eq)
Fields
  • mut index : UInt64
  • mut bytes : UInt64

Inflights

struct
Fields
  • mut start : Int
  • mut count : Int
  • mut bytes : UInt64
  • size : Int
  • max_bytes : UInt64
  • mut buffer : Array[Inflight]
Methods · 8
  • add(Self, UInt64, UInt64) Unit
  • clone(Self) Self
  • count(Self) Int
  • free_le(Self, UInt64) Unit
  • full(Self) Bool
  • max_bytes(Self) UInt64
  • new(Int, UInt64) Self
  • reset(Self) Unit

InstallSnapshotArgs

structderive(Eq)
Fields
  • term : UInt64
  • leader_id : String
  • last_index : UInt64
  • last_term : UInt64
  • offset : UInt64
  • data : Bytes
  • done : Bool
  • conf_state : ConfState
Methods · 1
  • whole(UInt64, String, Snapshot) Self

InstallSnapshotReply

structderive(Eq)
Fields
  • term : UInt64

LogLevel

enumderive(Eq)
Variants
  • Debug
  • Info
  • Warning
  • Error
  • Fatal
  • Panic

LogSlice

struct
Fields
  • term : UInt64
  • prev : @raftpb.EntryId
  • entries : Array[@raftpb.Entry]
Methods · 3
  • last_entry_id(Self) @raftpb.EntryId
  • last_index(Self) UInt64
  • valid(Self) Bool

Membership

struct
Fields
  • members : Array[String]
  • outgoing : Array[String]
  • mut joint : Bool
  • learners : Array[String]
  • learners_next : Array[String]
  • mut auto_leave : Bool
Methods · 17
  • add(Self, String) Unit
  • add_learner(Self, String) Unit
  • begin_joint(Self, Array[String]) Unit
  • committed_index(Self, Map[String, UInt64]) UInt64
  • contains(Self, String) Bool
  • enter_joint(Self, Array[String]) Unit
  • has_majority(Self, Array[String]) Bool
  • is_joint(Self) Bool
  • is_learner(Self, String) Bool
  • leave_joint(Self) Unit
  • new(Array[String]) Self
  • nodes(Self) Array[String]
  • quorum(Self) Int
  • remove(Self, String) Unit
  • size(Self) Int
  • vote_result(Self, Map[String, Bool]) @quorum.VoteState
  • voters(Self) Array[String]

MemoryStorage

struct
Fields
  • mut hard : @raftpb.HardState
  • mut snap : @raftpb.Snapshot
  • mut ents : Array[@raftpb.Entry]
  • mut snapshot_pending : Bool
Methods · 11
  • append(Self, Array[@raftpb.Entry]) Unit
  • apply_snapshot(Self, @raftpb.Snapshot) Unit raise StorageError
  • compact(Self, UInt64) Unit raise StorageError
  • create_snapshot(Self, UInt64, Bytes, conf_state? : @raftpb.ConfState?) @raftpb.Snapshot raise StorageError
  • from_ents(Array[@raftpb.Entry]) Self
  • new() Self
  • raw_ents(Self) Array[@raftpb.Entry]
  • seed_snapshot(Self, @raftpb.Snapshot) Unit
  • set_hard_state(Self, @raftpb.HardState) Unit
  • set_snapshot_pending(Self, Bool) Unit
  • slice(Self, UInt64, UInt64) Array[@raftpb.Entry]

NopLogger

struct

NopTracer

struct

Payload

enum
Variants
  • PreVote(RequestVoteArgs)
  • PreVoteResp(RequestVoteReply)
  • Vote(RequestVoteArgs)
  • VoteResp(RequestVoteReply)
  • Append(AppendEntriesArgs)
  • AppendResp(AppendEntriesReply)
  • Heartbeat(HeartbeatArgs)
  • HeartbeatResp(HeartbeatReply)
  • Snapshot(InstallSnapshotArgs)
  • TimeoutNow(UInt64)
  • Propose(Array[Entry])
  • ReadIndex(Bytes)
  • ReadIndexResp(ReadIndexResp)
  • TransferLeader(String)
  • ForgetLeader
Methods · 1
  • is_local(Self) Bool

Persisted

struct
Fields
  • term : UInt64
  • voted_for : String?
  • log : Array[@raftpb.Entry]

Progress

struct
Fields
  • mut next_index : UInt64
  • mut match_index : UInt64
  • mut state : ProgressState
  • mut recent_active : Bool
  • mut msg_app_flow_paused : Bool
  • mut pending_snapshot : UInt64
  • mut is_learner : Bool
  • mut sent_commit : UInt64
  • inflights : Inflights
Methods · 19
  • become_probe(Self) Unit
  • become_replicate(Self) Unit
  • become_snapshot(Self, UInt64) Unit
  • can_bump_commit(Self, UInt64) Bool
  • copy(Self) Self
  • free_le(Self, UInt64) Unit
  • is_active(Self) Bool
  • is_paused(Self) Bool
  • mark_active(Self) Unit
  • maybe_decr_to(Self, UInt64, UInt64) Bool
  • maybe_decrease(Self, UInt64) Bool
  • maybe_update(Self, UInt64) Bool
  • new(UInt64, max_inflight? : Int, max_inflight_bytes? : UInt64) Self
  • note_commit_sent(Self, UInt64) Unit
  • optimistic_advance(Self, UInt64) Unit
  • reset_active(Self) Unit
  • sent_entries(Self, UInt64, Bool, bytes? : UInt64) Unit
  • to_string(Self) String
  • unpause(Self) Unit

ProgressState

enumderive(Eq)
Variants
  • Probe
  • Replicate
  • Snapshot

ProgressStatus

structderive(Eq)
Fields
  • id : String
  • match_index : UInt64
  • next_index : UInt64
  • state : @tracker.ProgressState
  • paused : Bool
  • pending_snapshot : UInt64
  • is_learner : Bool

RaftLog

struct
Fields
  • storage : &@storage.RaftStorage
  • unstable : Unstable
  • mut committed : UInt64
  • mut applying : UInt64
  • mut applied : UInt64
  • max_applying_ents_size : UInt64
  • mut applying_ents_size : UInt64
  • mut applying_ents_paused : Bool
Methods · 40
  • accept_applying(Self, UInt64, UInt64, Bool) Unit
  • accept_unstable(Self) Unit
  • all_entries(Self) Array[@raftpb.Entry]
  • append(Self, Array[@raftpb.Entry]) UInt64
  • applied_to(Self, UInt64, UInt64) Unit
  • async_stabilize(Self, UInt64, UInt64) Unit
  • commit_stable(Self, Array[@raftpb.Entry]) Unit
  • commit_to(Self, UInt64) Unit
  • committed(Self) UInt64
  • entries(Self, UInt64, UInt64) Array[@raftpb.Entry] raise LogCompacted
  • find_conflict(Self, ArrayView[@raftpb.Entry]) UInt64
  • find_conflict_by_term(Self, UInt64, UInt64) (UInt64, UInt64)
  • first_index(Self) UInt64
  • has_next_committed_ents(Self, Bool) Bool
  • has_next_or_in_progress_unstable_ents(Self) Bool
  • has_next_unstable_ents(Self) Bool
  • has_next_unstable_snapshot(Self) Bool
  • is_up_to_date(Self, @raftpb.EntryId) Bool
  • last_entry_id(Self) @raftpb.EntryId
  • last_index(Self) UInt64
  • match_term(Self, @raftpb.EntryId) Bool
  • maybe_append(Self, LogSlice, UInt64) UInt64?
  • maybe_commit(Self, @raftpb.EntryId) Bool
  • must_check_out_of_bounds(Self, UInt64, UInt64) Unit raise LogCompacted
  • new(@storage.MemoryStorage) Self
  • new_with_size(&@storage.RaftStorage, UInt64) Self
  • next_committed_ents(Self, Bool) Array[@raftpb.Entry]
  • next_unstable_ents(Self) Array[@raftpb.Entry]
  • next_unstable_snapshot(Self) @raftpb.Snapshot?
  • pending_snapshot_index(Self) UInt64?
  • restore(Self, @raftpb.Snapshot) Unit
  • scan(Self, UInt64, UInt64, UInt64, (ArrayView[@raftpb.Entry]) -> Unit raise) Unit raise
  • seed(Self, UInt64, UInt64) Unit
  • slice(Self, UInt64, UInt64, UInt64) Array[@raftpb.Entry] raise LogCompacted
  • snapshot(Self) @raftpb.Snapshot raise @storage.StorageError
  • stable_snap_to(Self, UInt64) Unit
  • stable_to(Self, @raftpb.EntryId) Unit
  • term(Self, UInt64) UInt64 raise @storage.StorageError
  • to_string(Self) String
  • zero_term_on_out_of_bounds(Self, UInt64) UInt64

ReadIndexResp

structderive(Eq)
Fields
  • term : UInt64
  • index : UInt64
  • context : Bytes

ReadOnlyOption

enumderive(Eq)
Variants
  • Safe
  • LeaseBased

ReadState

structderive(Eq)
Fields
  • index : UInt64
  • request_ctx : Bytes

RequestVoteArgs

structderive(Eq)
Fields
  • term : UInt64
  • candidate_id : String
  • last_log_index : UInt64
  • last_log_term : UInt64

RequestVoteReply

structderive(Eq)
Fields
  • term : UInt64
  • vote_granted : Bool

Role

enumderive(Eq)
Variants
  • Follower
  • PreCandidate
  • Candidate
  • Leader

Snapshot

structderive(Eq)
Fields
  • last_index : UInt64
  • last_term : UInt64
  • data : Bytes
  • conf_state : ConfState
Methods · 2
  • empty() Self
  • is_empty(Self) Bool

SoftState

structderive(Eq)
Fields
  • lead : String?
  • state : Role
Methods · 1
  • equal(Self, Self) Bool

StorageAppend

struct
Fields
  • entries : Array[@raftpb.Entry]
  • hard_state : @raftpb.HardState?
  • snapshot : @raftpb.Snapshot?
  • resp : StorageAppendResp

StorageAppendResp

structderive(Eq)
Fields
  • index : UInt64
  • log_term : UInt64
  • term : UInt64

StorageApply

struct
Fields
  • entries : Array[@raftpb.Entry]
  • resp : StorageApplyResp

StorageApplyResp

struct
Fields
  • entries : Array[@raftpb.Entry]

TraceEvent

enum
Variants
  • InitState(String)
  • StateChange(String, Role, UInt64)
  • Commit(String, UInt64)
  • Replicate(String, Array[@raftpb.Entry])
  • SendMessage(@raftpb.Message)
  • ReceiveMessage(@raftpb.Message)
  • ConfChange(String, @raftpb.ConfState)

Unstable

struct
Fields
  • mut snapshot : @raftpb.Snapshot?
  • mut entries : Array[@raftpb.Entry]
  • mut offset : UInt64
  • mut offset_in_progress : UInt64
  • mut snapshot_in_progress : Bool
Methods · 12
  • accept_in_progress(Self) Unit
  • maybe_first_index(Self) UInt64?
  • maybe_last_index(Self) UInt64?
  • maybe_term(Self, UInt64) UInt64?
  • new(UInt64) Self
  • next_entries(Self) Array[@raftpb.Entry]
  • next_snapshot(Self) @raftpb.Snapshot?
  • restore(Self, @raftpb.Snapshot) Unit
  • slice(Self, UInt64, UInt64) Array[@raftpb.Entry]
  • stable_snap_to(Self, UInt64) Unit
  • stable_to(Self, @raftpb.EntryId) Unit
  • truncate_and_append(Self, Array[@raftpb.Entry]) Unit

VoteState

enumderive(Eq)
Variants
  • VoteWon
  • VoteLost
  • VotePending

WalRecord

enumderive(Eq)
Variants
  • WalHardState(@raftpb.HardState)
  • WalEntry(@raftpb.Entry)
  • WalSnapshot(@raftpb.Snapshot)