pub struct RaftNode { /* private fields */ }Expand description
High-level Raft node wrapper.
Owns the Raft<TypeConfig> instance and exposes the operations needed
by ClusterCoordinator: proposing mutations and checking leader status.
Implementations§
Source§impl RaftNode
impl RaftNode
Sourcepub async fn start(
local_raft_id: u64,
raft_addr: SocketAddr,
storage: Arc<Storage>,
secret: Option<Arc<ClusterSecret>>,
) -> Result<Self, Fatal<u64>>
pub async fn start( local_raft_id: u64, raft_addr: SocketAddr, storage: Arc<Storage>, secret: Option<Arc<ClusterSecret>>, ) -> Result<Self, Fatal<u64>>
Starts a Raft node bound to raft_addr.
Creates the Raft consensus engine, wraps storage with the openraft
adaptor, and spawns the TCP listener for inbound RPCs. When secret
is Some, all Raft frames are authenticated with HMAC-SHA256.
Sourcepub async fn bootstrap_single(&self) -> Result<(), String>
pub async fn bootstrap_single(&self) -> Result<(), String>
Initializes a single-node cluster.
Must only be called once, on first boot, before any log entries exist. Subsequent boots should NOT call this — the existing log is sufficient.
Sourcepub async fn propose(
&self,
cmd: ClusterCommand,
) -> Result<ClusterResponse, RaftProposalError>
pub async fn propose( &self, cmd: ClusterCommand, ) -> Result<ClusterResponse, RaftProposalError>
Proposes a cluster configuration change through Raft.
Blocks until the entry is committed and applied to the state machine
on a quorum of nodes. Returns NotLeader if this node is not the leader.
Sourcepub fn current_leader_node(&self) -> Option<BasicNode>
pub fn current_leader_node(&self) -> Option<BasicNode>
Returns the current leader’s BasicNode info, if known.
Sourcepub fn raft_handle(&self) -> &Raft<TypeConfig>
pub fn raft_handle(&self) -> &Raft<TypeConfig>
Exposes the underlying Raft handle for membership management.