amaters_cluster/lib.rs
1//! Consensus layer for AmateRS (Ukehi - The Sacred Pledge)
2//!
3//! This crate implements Raft consensus with support for encrypted logs
4//! and distributed cluster management.
5//!
6//! ## Architecture
7//!
8//! The consensus layer consists of:
9//!
10//! - **Raft Node**: Core consensus implementation with leader election and log replication
11//! - **Log Management**: Persistent log with in-memory cache and compaction
12//! - **State Management**: Persistent and volatile state tracking
13//! - **RPC Layer**: Request/response messages for inter-node communication
14//!
15//! ## Example
16//!
17//! ```rust,ignore
18//! use amaters_cluster::{RaftNode, RaftConfig, Command};
19//!
20//! // Create a 3-node cluster
21//! let config = RaftConfig::new(1, vec![1, 2, 3]);
22//! let node = RaftNode::new(config)?;
23//!
24//! // Propose a command (as leader)
25//! let cmd = Command::from_str("SET key value");
26//! let index = node.propose(cmd)?;
27//! ```
28
29pub mod error;
30pub mod log;
31pub mod node;
32pub mod rpc;
33pub mod state;
34pub mod types;
35
36// Re-exports for convenience
37pub use error::{RaftError, RaftResult};
38pub use log::{Command, LogEntry, RaftLog};
39pub use node::RaftNode;
40pub use rpc::{
41 AppendEntriesRequest, AppendEntriesResponse, RequestVoteRequest, RequestVoteResponse,
42};
43pub use state::{CandidateState, LeaderState, PersistentState, VolatileState};
44pub use types::{LogIndex, NodeId, NodeState, RaftConfig, Term};
45
46/// Library version
47pub const VERSION: &str = env!("CARGO_PKG_VERSION");
48
49/// Library name
50pub const NAME: &str = env!("CARGO_PKG_NAME");