Ruvector Raft
Raft consensus implementation for Ruvector distributed metadata coordination.
ruvector-raft provides a production-ready Raft consensus implementation for coordinating distributed Ruvector deployments. Ensures strong consistency for cluster metadata, configuration, and leader election. Part of the Ruvector ecosystem.
Why Ruvector Raft?
- Strong Consistency: Linearizable reads and writes
- Leader Election: Automatic failover on leader failure
- Log Replication: Durable, replicated transaction log
- Membership Changes: Dynamic cluster reconfiguration
- Snapshot Support: Log compaction via snapshots
Features
Core Capabilities
- Raft Consensus: Full Raft protocol implementation
- Leader Election: Randomized timeouts, pre-vote protocol
- Log Replication: Pipelined append entries
- Commit Management: Majority-based commit tracking
- State Machine: Generic state machine interface
Advanced Features
- Pre-Vote Protocol: Prevents disruption during network partitions
- Leadership Transfer: Graceful leader handoff
- Read Index: Linearizable reads without log entry
- Learner Nodes: Non-voting members for scaling reads
- Batch Commits: Coalesce multiple entries per commit
Installation
Add ruvector-raft to your Cargo.toml:
[]
= "0.1.1"
Quick Start
Create Raft Node
use ;
async
Implement State Machine
use ;
Propose Commands
// Propose a command (only succeeds on leader)
let response = node.propose.await?;
// Read with linearizable consistency
let response = node.read_index.await?;
// Check leadership
if node.is_leader.await
API Overview
Core Types
// Raft configuration
// Log entry
// Snapshot
// Node state
Node Operations
Architecture
┌────────────────────────────────────────────────────────┐
│ Raft Cluster │
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Node 1 │ │ Node 2 │ │ Node 3 │ │
│ │ (Leader) │───▶│(Follower)│ │(Follower)│ │
│ │ │ │ │ │ │ │
│ │ Log: │ │ Log: │ │ Log: │ │
│ │ [1,2,3] │───▶│ [1,2,3] │ │ [1,2,3] │ │
│ └──────────┘ └──────────┘ └──────────┘ │
│ │ ▲ │
│ └───────────────────────────────┘ │
│ AppendEntries RPC │
└────────────────────────────────────────────────────────┘
Related Crates
- ruvector-core - Core vector database engine
- ruvector-cluster - Clustering and sharding
- ruvector-replication - Data replication
Documentation
- Main README - Complete project overview
- API Documentation - Full API reference
- GitHub Repository - Source code
License
MIT License - see LICENSE for details.