From f67705e8f0ff511b5497b509783f9cee7ef2f986 Mon Sep 17 00:00:00 2001 From: rUv Date: Fri, 28 Nov 2025 03:28:00 +0000 Subject: [PATCH] docs: Add usage examples for distributed systems crates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add Rust code examples showing how to use: - ruvector-raft: 5-node Raft cluster configuration - ruvector-cluster: Consistent hash ring with auto-sharding - ruvector-replication: SemiSync multi-master replication 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index be509d961..56fa8c4bc 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,34 @@ let enhanced = layer.forward(&query, &neighbors, &weights); | **Snapshots** | Point-in-time backups, incremental | Disaster recovery | | **Cluster Metrics** | Prometheus-compatible monitoring | Observability at scale | +```bash +cargo add ruvector-raft ruvector-cluster ruvector-replication +``` + +```rust +use ruvector_raft::{RaftNode, RaftNodeConfig}; +use ruvector_cluster::{ClusterManager, ConsistentHashRing}; +use ruvector_replication::{SyncManager, SyncMode}; + +// Configure a 5-node Raft cluster +let config = RaftNodeConfig { + node_id: "node-1".into(), + cluster_members: vec!["node-1", "node-2", "node-3", "node-4", "node-5"] + .into_iter().map(Into::into).collect(), + election_timeout_min: 150, // ms + election_timeout_max: 300, // ms + heartbeat_interval: 50, // ms +}; +let raft = RaftNode::new(config); + +// Auto-sharding with consistent hashing (150 virtual nodes per real node) +let ring = ConsistentHashRing::new(64, 3); // 64 shards, replication factor 3 +let shard = ring.get_shard("my-vector-key"); + +// Multi-master replication with conflict resolution +let sync = SyncManager::new(SyncMode::SemiSync { min_replicas: 2 }); +``` + ### AI & ML | Feature | What It Does | Why It Matters |