1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/// Cluster Management for Multi-Node Scaling
///
/// Provides partition-based routing, term-based consensus, and membership management.
///
/// # Components
///
/// ## NodeRegistry
/// - Manages cluster nodes and health status
/// - Automatic partition rebalancing
/// - Deterministic partition assignment
///
/// ## RequestRouter
/// - Routes requests to correct node based on entity/partition
/// - Failover on node failures
/// - Load balancing for read operations
///
/// ## ClusterManager (consensus)
/// - Term-based leader election (simplified Raft)
/// - Deterministic leader selection (highest WAL offset, lowest ID tiebreak)
/// - Cluster membership management
/// - Integrates with NodeRegistry for partition replication
///
/// # Example
///
/// ```ignore
/// use allsource_core::infrastructure::cluster::{ClusterManager, ClusterMember, MemberRole};
///
/// // Create cluster manager (node 0, 32 partitions)
/// let cluster = ClusterManager::new(0, 32);
///
/// // Add members
/// cluster.add_member(ClusterMember {
/// node_id: 0,
/// api_address: "node-0:3900".to_string(),
/// replication_address: "node-0:3910".to_string(),
/// role: MemberRole::Leader,
/// last_wal_offset: 0,
/// last_heartbeat_ms: 0,
/// healthy: true,
/// }).await;
///
/// // Get cluster status
/// let status = cluster.status().await;
/// ```
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use RequestRouter;