feat(raft): add Raft consensus layer with openraft#98
Merged
Conversation
Implement the Raft consensus layer based on openraft 0.9, including: - TypeConfig with RaftRequest/RaftResponse enums for Put/Delete/Txn - AetherStateMachine: applies committed log entries to in-memory store (BTreeMap placeholder, will be replaced with RocksDB in next PR) - AetherLogStore: persists Raft logs and vote state in RocksDB column families (raft_log, raft_state) with sync writes - AetherNetwork: stub RaftNetwork implementation for inter-node RPC (will be wired with tonic gRPC in API layer PR) - SnapshotManager: disk-based snapshot file management Dependencies added: openraft, tonic, prost, rkyv, futures, serde_json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Raft consensus layer based on openraft 0.9. State machine uses in-memory BTreeMap as placeholder — will be replaced with RocksDB in the next PR.
Changes
src/raft/mod.rs — TypeConfig definition, RaftRequest/RaftResponse enums, and data types (KeyValue, Compare, etc.) shared across all Raft modules.
src/raft/state_machine.rs — RaftStateMachine implementation. Applies committed log entries: Put/Delete modify state, Txn supports compare-and-swap, Get/Range are read-only and don't go through Raft log.
src/raft/log_store.rs — RaftLogStorage implementation backed by RocksDB column families (raft_log, raft_state). All writes use sync for durability.
src/raft/network.rs — RaftNetworkFactory/RaftNetwork stub. Will be wired with tonic gRPC in the API layer PR.
src/raft/snapshot.rs — SnapshotManager for disk-based snapshot file I/O.
Cargo.toml — Added openraft, tonic, prost, rkyv, futures, serde_json dependencies.