ember_cluster/lib.rs
1//! ember-cluster: distributed coordination for ember.
2//!
3//! This crate provides the building blocks for running ember as a distributed
4//! cluster with automatic failover and horizontal scaling.
5//!
6//! # Architecture
7//!
8//! The cluster layer sits between the protocol layer and the storage engine,
9//! handling:
10//!
11//! - **Slot management**: 16384 hash slots distributed across nodes
12//! - **Topology tracking**: Node membership and health monitoring
13//! - **Failure detection**: SWIM gossip protocol for quick detection
14//! - **Consensus**: Raft for cluster configuration changes
15//! - **Migration**: Live slot resharding without downtime
16//!
17//! # Quick Start
18//!
19//! ```rust,no_run
20//! use ember_cluster::{ClusterState, ClusterNode, NodeId, key_slot};
21//!
22//! // Create a single-node cluster
23//! let node_id = NodeId::new();
24//! let node = ClusterNode::new_primary(node_id, "127.0.0.1:6379".parse().unwrap());
25//! let cluster = ClusterState::single_node(node);
26//!
27//! // Route a key to its slot
28//! let slot = key_slot(b"mykey");
29//! assert!(cluster.owns_slot(slot));
30//! ```
31
32mod auth;
33mod election;
34mod error;
35mod gossip;
36mod message;
37mod migration;
38mod raft;
39mod raft_log;
40mod raft_transport;
41mod slots;
42mod topology;
43
44pub use auth::ClusterSecret;
45pub use election::Election;
46pub use error::ClusterError;
47pub use gossip::{GossipConfig, GossipEngine, GossipEvent, MemberState, MemberStatus};
48pub use message::{GossipMessage, MemberInfo, NodeUpdate};
49pub use migration::{
50 Migration, MigrationBatch, MigrationConfig, MigrationEntry, MigrationError, MigrationId,
51 MigrationManager, MigrationRedirect, MigrationState,
52};
53pub use openraft::BasicNode;
54pub use raft::{
55 raft_id_from_node_id, ClusterCommand, ClusterResponse, ClusterSnapshot, ClusterStateData,
56 NodeInfo, RaftNetworkFactory, RaftNode, RaftProposalError, Storage as RaftStorage, TypeConfig,
57};
58pub use raft_log::RaftDiskError;
59pub use slots::{key_slot, SlotMap, SlotRange, SLOT_COUNT};
60pub use topology::{
61 ClusterHealth, ClusterNode, ClusterState, ConfigParseError, NodeFlags, NodeId, NodeRole,
62};