Skip to main content

Crate mocra_cluster

Crate mocra_cluster 

Source
Expand description

mocra-cluster: the embedded control plane (refactor Phase 3).

The control plane uses a redb state machine + Raft consensus to provide strongly consistent membership / locks / KV / partition ownership; the data plane (queues) still goes through the main crate’s pluggable MqBackend.

§Current progress

  • ✅ redb replicated state machine (StateMachine): kv / locks (with monotonic fencing tokens).
  • ✅ Single-node control plane (LocalControlPlane): set/get/cas/acquire_lock/renew_lock/release_lock.
  • ✅ openraft consensus layered on top of the state machine (RaftControlPlane): persistent log + snapshots.
  • ✅ Membership / join API + partition ownership (partition: rendezvous assignment + Raft fencing leases).
  • ✅ On the main crate side, RaftCoordinationBackend adapts CoordinationBackend to provide cluster coordination.

Re-exports§

pub use cmd::Cmd;
pub use cmd::CmdResult;
pub use cmd::Lock;
pub use control::ControlError;
pub use control::ControlPlane;
pub use control::LocalControlPlane;
pub use partition::DEFAULT_PARTITIONS;
pub use partition::owner_of_partition;
pub use partition::owns_key;
pub use partition::partition_of;
pub use partition::partitions_owned_by;
pub use raft::MocraRaft;
pub use raft::Node;
pub use raft::NodeId;
pub use raft::TypeConfig;
pub use raft_http::JoinRequest;
pub use raft_node::ClusterStatus;
pub use raft_node::RaftControlPlane;
pub use raft_node::RaftTuning;
pub use state_machine::StateMachine;
pub use state_machine::StateMachineError;

Modules§

cmd
State machine commands and results.
control
Control plane API: strongly consistent KV + distributed locks on top of the state machine.
partition
Partition ownership (refactor Phase 3): spreads collection work across cluster nodes by partition.
raft
openraft type configuration: wires the control plane’s Cmd / CmdResult into Raft (openraft 0.9.24).
raft_http
Node-to-node control plane RPC: HTTP + msgpack.
raft_log_store
redb-persisted Raft log storage.
raft_network
Stub network for single-node deployments.
raft_node
Single-node Raft control plane: assembles the openraft node; commands are committed through Raft and then applied to the redb state machine.
raft_store
Raft storage: in-memory log + redb state machine.
state_machine
A redb-backed replicated state machine.