Skip to main content

ControlPlaneConsensus

Trait ControlPlaneConsensus 

Source
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 ControlPlaneTerm and the elected leader;
  • append a ControlPlaneEntryleader-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§

Source

fn current_term(&self) -> ControlPlaneTerm

The current Supervisor election term.

Source

fn leader(&self) -> Option<ClusterVoterIdentity>

The current Supervisor leader, if one is elected for current_term.

Source

fn is_leader(&self) -> bool

Is this node the current Supervisor leader?

Source

fn durable_vote(&self) -> DurableVoteState

The durable per-node vote state, persisted before acknowledging a vote.

Source

fn commit_index(&self) -> Option<ControlPlaneIndex>

The index of the highest committed entry, or None if the log is empty.

Source

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".

Implementors§