A distributed key-value project built with OpenRaft 0.10.0-alpha.15 and SurrealKV.
| English | 简体中文 |
openraft::Raft runtime is wired in.RaftLogStorageRaftLogReaderRaftStateMachineRaftSnapshotBuilderdocs/USAGE_GUIDE.mddocs/USAGE_GUIDE_CN.mdsrc/
app.rs # RaftNode wrapper (startup/write/read/shutdown)
config.rs # Config model + strict validation
main.rs # Process entrypoint
storage.rs # SurrealStorage core
storage_raft_impl.rs # OpenRaft trait implementations
network/ # gRPC client/server
tests/
common/cluster_harness.rs # Shared 3-node integration harness
cluster_observability.rs # Election + replication visibility integration tests
See config.toml.example.
Important fields in [cluster]:
bootstrap: whether this node performs initializeexpected_voters: expected voter count (self + peers)peers: peer list (node_id, addr)Strict validation rules in src/config.rs:
node_id is rejectedaddr is rejectedpeersaddr must not equal local listen_addrexpected_voters must be > 0 (if set)expected_voters must equal 1 + peers.len() (strict, regardless of bootstrap)Single node:
cargo run -- --config config.toml.example
Multi-node:
cluster.bootstrap = true on exactly one node.cluster.expected_voters consistent across all nodes.Regular tests:
cargo test
Feature-gated 3-node integration tests:
cargo test --features integration-cluster --test cluster_observability
Run one integration case:
cargo test --features integration-cluster --test cluster_observability test_three_node_election_observability
cargo test --features integration-cluster --test cluster_observability test_three_node_replication_visibility
The merge pipeline uses stable MERGE_* codes from src/merge/error_codes.rs.
| Error Code | Meaning | Typical Trigger |
|---|---|---|
MERGE_BASELINE_MISSING |
No baseline checkpoint metadata in snapshot state | merge starts before baseline is persisted |
MERGE_BASELINE_PATH_REQUIRED |
Strict mode requires explicit checkpoint_path |
legacy/incomplete metadata without path |
MERGE_BASELINE_PATH_MISSING |
checkpoint_path is set but directory does not exist |
checkpoint files removed/corrupted |
MERGE_INJECTED_FAILURE |
Test-only injected backend failure | integration/unit fault injection |
MERGE_UNKNOWN |
Fallback code when parser cannot extract a known prefix | non-standard merge error format |
raft_snapshot_merge_failed_total and failed raft_snapshot_merge_duration_ms samples carry:
trigger: merge trigger reason (chain_length, delta_bytes, checkpoint_interval)error_code: stable merge failure code (from table above)node_id, retries, result=failedExample query dimensions for dashboards/alerts:
error_code="MERGE_BASELINE_PATH_MISSING"node_id with increasing retriestriggerMIT OR Apache-2.0