Skip to main content

Crate tokioraft

Crate tokioraft 

Source
Expand description

tokioraft is a small Tokio-oriented leader election library.

The crate implements a minimal Raft-inspired election state machine. It reacts to incoming peer messages, drives local election timers, and emits outgoing election messages together with local role changes.

tokioraft is intentionally narrow in scope:

  • it does leader election only
  • it does not implement a replicated log
  • it does not provide networking or node discovery
  • it does not manage cluster membership automatically

Typical integration flow:

  1. Create one TinyRaft instance per node
  2. Read events from TinyRaft::get_receiver_from_raft
  3. Deliver send::MsgRouter::ToNode messages using your own transport
  4. Feed received peer messages back through TinyRaft::on_receive
  5. Apply membership changes explicitly through TinyRaft::set_nodes

The library is intended for Tokio-based applications and expects the host application not to block Tokio worker threads for long periods of time.

Modules§

error
inner
send

Structs§

TinyRaft
A running leader-election node.

Enums§

NodeType
Current election role of a node.

Type Aliases§

NodeId
Unique node identifier used by the election state machine.