pub trait ControlPlaneConsensus {
// Required methods
fn current_term(&self) -> ControlPlaneTerm;
fn leader(&self) -> Option<ClusterVoterIdentity>;
fn is_leader(&self) -> bool;
fn durable_vote(&self) -> DurableVoteState;
fn commit_index(&self) -> Option<ControlPlaneIndex>;
fn append(
&mut self,
entry: ControlPlaneEntry,
) -> Result<ControlPlaneIndex, ControlPlaneError>;
}Expand description
The small internal abstraction over the Cluster Supervisor control-plane consensus engine.
This trait is the seam the HITL decision asked for: follow-up slices depend
on this, not on a concrete Raft library or hand-rolled protocol. The first
implementation may be a degenerate single-node engine
(SingleNodeControlPlane); a later slice may back it with a fully
replicated, persisted log. Neither change reaches the callers.
The trait deliberately exposes only what the boundary needs:
- read the current
ControlPlaneTermand the electedleader; - append a
ControlPlaneEntry— leader-only, which is how “the Supervisor leader is the normal writer for ownership transitions” is enforced rather than documented; and - read the durable
DurableVoteState, so the election safety obligation is part of the contract.
Required Methods§
Sourcefn current_term(&self) -> ControlPlaneTerm
fn current_term(&self) -> ControlPlaneTerm
The current Supervisor election term.
Sourcefn leader(&self) -> Option<ClusterVoterIdentity>
fn leader(&self) -> Option<ClusterVoterIdentity>
The current Supervisor leader, if one is elected for current_term.
Sourcefn durable_vote(&self) -> DurableVoteState
fn durable_vote(&self) -> DurableVoteState
The durable per-node vote state, persisted before acknowledging a vote.
Sourcefn commit_index(&self) -> Option<ControlPlaneIndex>
fn commit_index(&self) -> Option<ControlPlaneIndex>
The index of the highest committed entry, or None if the log is empty.
Sourcefn append(
&mut self,
entry: ControlPlaneEntry,
) -> Result<ControlPlaneIndex, ControlPlaneError>
fn append( &mut self, entry: ControlPlaneEntry, ) -> Result<ControlPlaneIndex, ControlPlaneError>
Append a control-plane entry as the leader.
Returns the committed ControlPlaneIndex on success, or
ControlPlaneError::NotLeader if this node is not the leader — a
follower must forward the request to the leader rather than write
locally. By construction, the entry cannot carry user data.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".