rivven-cluster
Distributed cluster coordination for Rivven.
Features
- Raft Consensus - Leader election and log replication using OpenRaft
- SWIM Gossip - Failure detection and membership management
- Partitioning - Consistent hashing for partition assignment
- QUIC Transport - Efficient, secure node-to-node communication
Architecture
┌─────────────────────────────────────────────────────────────────┐
│ rivven-cluster │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Raft │ │ SWIM │ │ Partition │ │
│ │ Consensus │ │ Gossip │ │ Manager │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │ │ │ │
│ └───────────────────┼───────────────────┘ │
│ │ │
│ ┌────────────────┐ │
│ │ QUIC Transport │ │
│ └────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘
Components
Raft Consensus
Used for metadata replication and leader election:
use ;
let config = RaftConfig ;
let node = new.await?;
SWIM Gossip
Decentralized failure detection:
use ;
let config = SwimConfig ;
let node = new.await?;
Partition Assignment
Consistent hashing with virtual nodes:
use ;
let ring = new; // 128 virtual nodes per physical node
ring.add_node?;
ring.add_node?;
let owner = ring.get_partition_owner?;
Configuration
cluster:
node_id: 1
bind_address: "0.0.0.0:9093"
raft:
peers:
- "node2:9093"
- "node3:9093"
election_timeout_min_ms: 150
election_timeout_max_ms: 300
gossip:
bind_port: 7946
known_peers:
- "node2:7946"
protocol_period_ms: 1000
partitioning:
virtual_nodes: 128
replication_factor: 3
License
See root LICENSE file.