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,ignore
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 error;
33mod gossip;
34mod message;
35mod migration;
36mod raft;
37mod slots;
38mod topology;
39
40pub use error::ClusterError;
41pub use gossip::{GossipConfig, GossipEngine, GossipEvent, MemberState, MemberStatus};
42pub use message::{GossipMessage, MemberInfo, NodeUpdate};
43pub use migration::{
44 Migration, MigrationBatch, MigrationConfig, MigrationEntry, MigrationError, MigrationId,
45 MigrationManager, MigrationRedirect, MigrationState,
46};
47pub use raft::{
48 ClusterCommand, ClusterResponse, ClusterSnapshot, ClusterStateData, Storage as RaftStorage,
49 TypeConfig,
50};
51pub use slots::{key_slot, SlotMap, SlotRange, SLOT_COUNT};
52pub use topology::{ClusterHealth, ClusterNode, ClusterState, NodeFlags, NodeId, NodeRole};