1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//! 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](https://github.com/datafuselabs/openraft/blob/main/examples/basic_usage.rs)
//! for a complete demonstration of core functionality, including:
//!
//! Basic usage:
//!
//! ```rust
//! # use std::io;
//! # use std::sync::Arc;
//! # use std::sync::mpsc::sync_channel;
//! # use std::sync::mpsc::SyncSender;
//! use raft_log::{RaftLog, Config, Types};
//!
//! use raft_log::api::raft_log_writer::RaftLogWriter;
//!
//! // Define your application-specific types
//! #[derive(Debug, Clone, PartialEq, Eq, Default)]
//! struct MyTypes;
//! impl Types for MyTypes {
//! type LogId = (u64, u64); // (term, index)
//! type LogPayload = String; // Log entry data
//! type Vote = (u64, u64); // (term, voted_for)
//! type UserData = String; // Custom user data
//! type Callback = SyncSender<io::Result<()>>;
//!
//! fn log_index(log_id: &Self::LogId) -> u64 {
//! log_id.1
//! }
//!
//! fn payload_size(payload: &Self::LogPayload) -> u64 {
//! payload.len() as u64
//! }
//! }
//!
//! // Open a RaftLog instance
//! let temp_dir = tempfile::tempdir().unwrap();
//! let config = Arc::new(Config {
//! dir: temp_dir.path().to_str().unwrap().to_string(),
//! ..Default::default()
//! });
//! let mut raft_log = RaftLog::<MyTypes>::open(config).unwrap();
//!
//! // Save vote information
//! raft_log.save_vote((1, 2)).unwrap(); // Voted for node-2 in term 1
//!
//! // Append log entries
//! let entries = vec![
//! ((1, 1), "first entry".to_string()),
//! ((1, 2), "second entry".to_string()),
//! ];
//! raft_log.append(entries).unwrap();
//!
//! // Update commit index
//! raft_log.commit((1, 2)).unwrap();
//!
//! // Flush changes to disk with callback
//! let (tx, rx) = sync_channel(1);
//! raft_log.flush(Some(tx)).unwrap();
//! rx.recv().unwrap().unwrap();
//! ```
pub
pub
pub
pub
pub
pub use codeq;
pub use Types;
pub use ChunkId;
pub use Config;
pub use ChunkStat;
pub use Stat;
pub use Callback;
pub use Dump;
pub use DumpApi;
pub use DumpRaftLog;
pub use DumpRaftLogIter;
pub use RaftLog;
pub use WALRecord;
pub use crateSegment;