Skip to main content

Crate amaters_cluster

Crate amaters_cluster 

Source
Expand description

Consensus layer for AmateRS (Ukehi - The Sacred Pledge)

This crate implements Raft consensus with support for encrypted logs and distributed cluster management.

§Architecture

The consensus layer consists of:

  • Raft Node: Core consensus implementation with leader election and log replication
  • Log Management: Persistent log with in-memory cache and compaction
  • State Management: Persistent and volatile state tracking
  • RPC Layer: Request/response messages for inter-node communication

§Example

use amaters_cluster::{RaftNode, RaftConfig, Command};

// Create a 3-node cluster
let config = RaftConfig::new(1, vec![1, 2, 3]);
let node = RaftNode::new(config)?;

// Propose a command (as leader)
let cmd = Command::from_str("SET key value");
let index = node.propose(cmd)?;

Re-exports§

pub use encryption::EncryptedPayload;
pub use encryption::EntryEncryptor;
pub use encryption::LogEncryptionKey;
pub use encryption::LogIntegrityVerifier;
pub use error::RaftError;
pub use error::RaftResult;
pub use failover::FailoverConfig;
pub use failover::FailoverCoordinator;
pub use failover::FailoverEvent;
pub use heartbeat::FailureDetector;
pub use log::ApplyResult;
pub use log::Command;
pub use log::LogEntry;
pub use log::RaftLog;
pub use log::SnapshotData;
pub use log::StateMachine;
pub use metrics::ClusterMetrics;
pub use node::RaftNode;
pub use persistence::FilePersistence;
pub use persistence::MemoryPersistence;
pub use persistence::RaftPersistence;
pub use rpc::AppendEntriesRequest;
pub use rpc::AppendEntriesResponse;
pub use rpc::RequestVoteRequest;
pub use rpc::RequestVoteResponse;
pub use snapshot::DiskSnapshotStore;
pub use snapshot::InstallSnapshotRequest;
pub use snapshot::InstallSnapshotResponse;
pub use snapshot::Snapshot;
pub use snapshot::SnapshotConfig;
pub use snapshot::SnapshotManager;
pub use snapshot::SnapshotMetadata;
pub use snapshot::SnapshotPolicy;
pub use snapshot::SnapshotReceiver;
pub use snapshot::SnapshotStore;
pub use state::CandidateState;
pub use state::FencingTokenState;
pub use state::LeaderState;
pub use state::PersistentState;
pub use state::VolatileState;
pub use types::ClusterConfig;
pub use types::ConfigState;
pub use types::FailureEvent;
pub use types::FencingToken;
pub use types::HeartbeatConfig;
pub use types::LogIndex;
pub use types::MembershipChange;
pub use types::NodeId;
pub use types::NodeState;
pub use types::RaftConfig;
pub use types::Term;
pub use wal::CorruptionPolicy;
pub use wal::SyncMode;
pub use wal::WalDiagnostics;
pub use wal::WalReader;
pub use wal::WalWriter;

Modules§

encryption
AES-256-GCM encryption and HMAC-SHA256 integrity for Raft log payloads.
error
Error types for the Raft consensus module
failover
Automatic failover coordination for Raft clusters.
heartbeat
Heartbeat-based failure detection for cluster peers.
log
Log management for Raft consensus
metrics
Prometheus-compatible metrics for the AmateRS cluster consensus layer.
node
Main Raft node implementation
persistence
Persistent storage backends for Raft consensus
rpc
RPC message types for Raft consensus
snapshot
Snapshot management and log compaction for Raft consensus
state
Raft persistent and volatile state
types
Core types for Raft consensus
wal
Segment-based Write-Ahead Log (WAL) with CRC32 integrity and fsync.

Constants§

NAME
Library name
VERSION
Library version