pub struct ConsensusConfig {
pub cluster_name: String,
pub election_timeout_min_ms: u64,
pub election_timeout_max_ms: u64,
pub heartbeat_interval_ms: u64,
pub snapshot_logs_since_last: u64,
pub max_payload_entries: u64,
pub rpc_timeout: Duration,
pub snapshot_timeout: Duration,
}Expand description
Configuration for a consensus node.
Wraps both openraft’s Config and network-level timeout settings.
Fields§
§cluster_name: StringHuman-readable cluster name (used in logs).
election_timeout_min_ms: u64Minimum election timeout in milliseconds.
A follower will start an election if it has not heard from the leader in at least this many milliseconds. Setting this to 7-15x the heartbeat interval prevents spurious elections while still detecting failures quickly.
Default: 1500ms (7.5x default heartbeat).
election_timeout_max_ms: u64Maximum election timeout in milliseconds.
The actual election timeout is randomized between min and max to prevent split-vote scenarios.
Default: 3000ms (15x default heartbeat).
heartbeat_interval_ms: u64Heartbeat interval in milliseconds.
The leader sends heartbeats at this interval to maintain authority.
Default: 200ms.
snapshot_logs_since_last: u64Number of log entries since the last snapshot before triggering a new one.
Default: 10,000 entries.
max_payload_entries: u64Maximum number of entries per AppendEntries RPC payload.
Default: 300.
rpc_timeout: DurationTimeout for vote and append_entries RPCs.
Default: 5 seconds.
snapshot_timeout: DurationTimeout for snapshot transfer RPCs.
Snapshots can be large, so this should be significantly longer than the normal RPC timeout.
Default: 60 seconds.
Implementations§
Source§impl ConsensusConfig
impl ConsensusConfig
Sourcepub fn to_openraft_config(&self) -> Result<Config, ConfigError>
pub fn to_openraft_config(&self) -> Result<Config, ConfigError>
Build an openraft Config from this consensus config.
§Errors
Returns an error if the resulting openraft config fails validation
(e.g., election_timeout_min > election_timeout_max).
Trait Implementations§
Source§impl Clone for ConsensusConfig
impl Clone for ConsensusConfig
Source§fn clone(&self) -> ConsensusConfig
fn clone(&self) -> ConsensusConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more