Expand description
§d-engine-core
Pure Raft consensus algorithm - for building custom Raft-based systems
§⚠️ Internal Crate - Not Ready for Standalone Use
Use d-engine instead.
This crate contains the pure Raft consensus algorithm used internally by d-engine. The API is unstable before v1.0.
# ❌ Don't use this directly
[dependencies]
d-engine-core = "0.2"
# ✅ Use this instead
[dependencies]
d-engine = "0.2"§For Contributors
§What this crate provides
This crate focuses solely on the Raft consensus algorithm:
- Leader Election - Automatic leader election with randomized timeouts
- Log Replication - Reliable log replication to followers
- Membership Changes - Dynamic cluster membership changes
- Snapshot Support - Log compaction via snapshots
Storage, networking, and state machine implementation are your responsibility.
Reference integration: See how d-engine-server uses this crate.
§Future Vision
Post-1.0 goal: Become a standalone Raft library with stable API.
Current status: Internal to d-engine, API may change between minor versions.
§Key Traits
StorageEngine- Persistent storage for Raft logsStateMachine- Application-specific state transitionsLogStore- Log entry persistenceMetaStore- Metadata persistence (term, voted_for)
§Documentation
For comprehensive guides:
Re-exports§
pub use config::*;pub use watch::*;pub use test_utils::*;
Modules§
- __
mock_ Mock Commit Handler - __
mock_ Mock Commit Handler_ Commit Handler - __
mock_ Mock Election Core - __
mock_ Mock Election Core_ Election Core_ 13065831140148901594 - __
mock_ Mock LogStore - __
mock_ Mock LogStore_ LogStore - __
mock_ Mock Membership - __
mock_ Mock Membership_ Membership_ 13065831140148901594 - __
mock_ Mock Meta Store - __
mock_ Mock Meta Store_ Meta Store - __
mock_ Mock Purge Executor - __
mock_ Mock Purge Executor_ Purge Executor - __
mock_ Mock Replication Core - __
mock_ Mock Replication Core_ Replication Core_ 13065831140148901594 - __
mock_ Mock Snapshot Policy - __
mock_ Mock Snapshot Policy_ Snapshot Policy - __
mock_ Mock State Machine - __
mock_ Mock State Machine Handler - __
mock_ Mock State Machine Handler_ State Machine Handler_ 13065831140148901594 - __
mock_ Mock State Machine_ State Machine - __
mock_ Mock Transport - __
mock_ Mock Transport_ Transport_ 13065831140148901594 - config
- Configuration management module for distributed Raft consensus engine.
- test_
utils - the test_utils folder here will share utils or test components betwee unit tests and integrations tests
- watch
- Watch mechanism for monitoring key changes
Structs§
- Append
Response With Updates - AppendEntries response with possible state changes
- Append
Result - Append
Results - Batch
Buffer - Cluster
Metadata - Cached cluster topology metadata for hot path optimization.
- Cluster
Update Result - Commit
Handler Dependencies - Default
Commit Handler - Default
Purge Executor - Default implementation using the configured log storage
- Default
State Machine Handler - Election
Handler - Leader
Info - Leader election information Used at: Application layer (internal Raft protocol notifications) Purpose: Notify applications about leader changes via watch channel Fields: Minimal - only what Raft protocol needs
- LogSize
Policy - Maybe
Clone Oneshot - Maybe
Clone Oneshot Receiver - Maybe
Clone Oneshot Sender - Mock
Commit Handler - Mock
Election Core - Mock
LogStore - Mock
Membership - Mock
Meta Store - Metadata storage operations
- Mock
Purge Executor - Defines the behavior for log entry compaction and physical deletion.
- Mock
Replication Core - Core replication protocol operations
- Mock
Snapshot Policy - Mock
State Machine - State machine trait for Raft consensus
- Mock
State Machine Handler - Mock
Transport - NewCommit
Data - Peer
Update - Raft
- Raft
Context - Raft
Core Handlers - Raft
Request With Signal - Request with response channel that can handle all Raft payload types
- Raft
Storage Handles - Replication
Data - Replication
Handler - Signal
Params - Snapshot
Context - Snapshot
Transfer Meta - Unified snapshot metadata with precomputed values
- State
Update - State transition data for election outcomes
- Stream
Response Sender - Vote
Result
Enums§
- Connection
Type - Consensus
Error - Convert
Error - Error type for value conversion operations
- Election
Error - Error
- File
Error - IdAllocation
Error - Membership
Error - Network
Error - Prost
Error - Wrapper for prost encoding/decoding errors
- Quorum
Status - Raft
Event - Read
Send Error - Replication
Error - Role
Event - Serialization
Error - Snapshot
Error - Storage
Error - System
Error - Test
Event - Write
Send Error
Traits§
- Commit
Handler - Election
Core - Lease
- Lease management interface for key expiration.
- LogStore
- Membership
- Meta
Store - Metadata storage operations
- Purge
Executor - Defines the behavior for log entry compaction and physical deletion.
- Raft
Oneshot - Replication
Core - Core replication protocol operations
- Snapshot
Policy - State
Machine - State machine trait for Raft consensus
- State
Machine Handler - Storage
Engine - High-performance storage abstraction for Raft consensus
- Transport
Functions§
- client_
command_ to_ entry_ payloads - Converts a vector of client WriteCommands into a vector of EntryPayloads. Each WriteCommand is serialized into bytes and wrapped in an EntryPayload::Command variant.
- ensure_
safe_ join - grpc_
task_ with_ timeout_ and_ exponential_ backoff - As soon as task has return we should return from this function
- raft_
event_ to_ test_ event