pub struct RaftConfig {Show 14 fields
pub node_id: NodeId,
pub peers: Vec<NodeId>,
pub election_timeout_range: (u64, u64),
pub heartbeat_interval: u64,
pub max_entries_per_message: usize,
pub enable_compaction: bool,
pub snapshot_threshold: u64,
pub max_snapshots: usize,
pub snapshot_dir: Option<PathBuf>,
pub persistence_dir: Option<PathBuf>,
pub wal_dir: Option<PathBuf>,
pub sync_on_write: bool,
pub snapshot_chunk_threshold_bytes: u64,
pub snapshot_chunk_size_bytes: usize,
}Expand description
Configuration for a Raft node
Fields§
§node_id: NodeIdThis node’s ID
peers: Vec<NodeId>List of all peer node IDs (including this node)
election_timeout_range: (u64, u64)Election timeout range (min, max) in milliseconds
heartbeat_interval: u64Heartbeat interval in milliseconds
max_entries_per_message: usizeMaximum number of entries to send in a single AppendEntries RPC
enable_compaction: boolWhether to enable log compaction
snapshot_threshold: u64Snapshot threshold (number of log entries before triggering snapshot)
max_snapshots: usizeMaximum number of snapshots to retain on disk
snapshot_dir: Option<PathBuf>Directory for storing snapshots (None = snapshots disabled on disk)
persistence_dir: Option<PathBuf>Directory for Raft persistent state and log (None = in-memory only)
wal_dir: Option<PathBuf>Directory for segment-based WAL replay on startup (None = WAL replay disabled)
sync_on_write: boolWhether to fsync after every persistent write (default: true)
snapshot_chunk_threshold_bytes: u64Max snapshot size in bytes before switching to chunked streaming. Default: 4 MiB.
snapshot_chunk_size_bytes: usizeChunk size in bytes for large snapshot streaming. Default: 1 MiB.
Implementations§
Source§impl RaftConfig
impl RaftConfig
Sourcepub fn new(node_id: NodeId, peers: Vec<NodeId>) -> Self
pub fn new(node_id: NodeId, peers: Vec<NodeId>) -> Self
Create a new Raft configuration with sensible defaults
Sourcepub fn random_election_timeout(&self) -> Duration
pub fn random_election_timeout(&self) -> Duration
Get a random election timeout within the configured range
Sourcepub fn heartbeat_interval(&self) -> Duration
pub fn heartbeat_interval(&self) -> Duration
Get the heartbeat interval
Sourcepub fn quorum_size(&self) -> usize
pub fn quorum_size(&self) -> usize
Calculate the quorum size (majority)
Trait Implementations§
Source§impl Clone for RaftConfig
impl Clone for RaftConfig
Source§fn clone(&self) -> RaftConfig
fn clone(&self) -> RaftConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RaftConfig
impl RefUnwindSafe for RaftConfig
impl Send for RaftConfig
impl Sync for RaftConfig
impl Unpin for RaftConfig
impl UnsafeUnpin for RaftConfig
impl UnwindSafe for RaftConfig
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.