raft-log
Log Storage for raft
A high-performance, reliable local disk-based log storage implementation for the raft consensus protocol.
Features
- Type-safe API with generic types for log entries, vote information, and user data
- Asynchronous write operations with callback support
- Efficient batch processing and disk I/O
- Core raft operations support:
- Vote persistence for election safety
- Log entry append for replication
- Commit index management
- Log entry reads for state machine application
Example
See basic usage example for a complete demonstration of core functionality, including:
- Creating and opening a raft log store
- Saving vote information during elections
- Appending log entries (as a leader or follower)
- Updating commit index
- Reading committed entries
- Getting current log state
- Using asynchronous flush with callbacks
Basic usage:
use ;
// Define your application-specific types
// Open a RaftLog instance
let config = new;
let mut raft_log = open?;
// Save vote information
raft_log.save_vote?; // Voted for node-2 in term 1
// Append log entries
let entries = vec!;
raft_log.append?;
// Update commit index
raft_log.commit?;
// Flush changes to disk with callback
let = sync_channel;
raft_log.flush?;
rx.recv.unwrap?;
For more examples and detailed documentation, see the examples directory.
License
This project is licensed under the Apache License, Version 2.0.