pub struct RaftConfig {
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: 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: usizeSnapshot threshold (number of log entries before triggering snapshot)
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
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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 UnwindSafe for RaftConfig
Blanket Implementations§
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
Mutably borrows from an owned value. Read more