项目/raft-zig

更新于 2026/07/25

raft-zig

将 raftpp 逐步移植到 Zig 的 Raft 实现,配套不变量检查、sanitizer 与 fuzzing 基础设施。

raft-zig 是 raftpp 的 Zig 移植项目,并沿用 grpc-lite 的构建与模块约定。目标是将 Raft core、存储、WAL、transport 和高层事件循环逐层转换为适合 Zig allocator 与 error union 的实现。

当前基础

  • Raft entry、message、hard state、configuration state 与 snapshot 等核心数据类型。
  • simple 与 joint consensus configuration change 的数据模型。
  • 使用 Zig error union 统一替代 C++ Result<T, RaftError> 的错误边界。
  • Debug 和 ReleaseSafe 构建中的快速 Raft invariant check。
  • 面向 codec、WAL、configuration change 和 simulation 的 bounded fuzz target。
  • Debug、ReleaseSafe、ThreadSanitizer 与 UBSan 等构建和测试任务。

CI 和 nightly fuzzing 当前均通过。simulation target 检查核心 Raft safety 与网络分区后的收敛,但应用状态机和 snapshot state 的端到端收敛仍属于后续完整链路。

开发状态

项目采用 MIT License,但仍处于 scaffold 阶段,目前没有 release。完整 consensus state machine、storage、WAL、RPC transport 和 Raftor orchestration 正在逐步落地。

README 中列出的 leader election、joint consensus、linearizable read、segmented WAL 和 grpc-lite transport 是目标架构,不应视为已经可用于生产的完整能力。当前更适合观察 C++ Raft 设计如何映射到 Zig 的类型、内存和错误模型,以及测试基础设施如何先于完整实现建立起来。

相关阅读

长文TLA+ 学习笔记长文阿里盘古性能导向的演进长文PolarFS: An Ultra-low Latency and Failure Resilient Distributed File System for Shared Storage Cloud Database