pub struct RaftNodeConfig {
pub cluster: ClusterConfig,
pub network: NetworkConfig,
pub raft: RaftConfig,
pub retry: RetryPolicies,
pub tls: TlsConfig,
}Expand description
Main configuration container for Raft consensus engine components
Combines all subsystem configurations with hierarchical override support:
- Default values from code implementation
- Configuration file specified by
CONFIG_PATH - Environment variables (highest priority)
Fields§
§cluster: ClusterConfigCluster topology and node configuration
network: NetworkConfigNetwork communication parameters
raft: RaftConfigCore Raft algorithm parameters
retry: RetryPoliciesRetry policies for distributed operations
tls: TlsConfigTLS/SSL security configuration
Implementations§
Source§impl RaftNodeConfig
impl RaftNodeConfig
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Creates a new configuration with hierarchical override support:
Configuration sources are merged in the following order (later sources override earlier ones):
- Type defaults (lowest priority)
- Configuration file from
CONFIG_PATHenvironment variable - Environment variables with
RAFT__prefix (highest priority)
§Returns
Merged configuration instance or error if:
- Config file parsing fails
- Validation rules are violated
§Example
// Load with default values only
let cfg = RaftNodeConfig::new()?;
// Load with config file and environment variables
std::env::set_var("CONFIG_PATH", "config/cluster.toml");
std::env::set_var("RAFT__CLUSTER__NODE_ID", "100");
let cfg = RaftNodeConfig::new()?;Sourcepub fn with_override_config(&self, path: &str) -> Result<Self>
pub fn with_override_config(&self, path: &str) -> Result<Self>
Creates a new configuration with additional overrides:
Merging order (later sources override earlier ones):
- Current configuration values
- New configuration file
- Latest environment variables (highest priority)
§Example
// Initial configuration
let base = RaftNodeConfig::new()?;
// Apply runtime overrides
let final_cfg = base.with_override_config("runtime_overrides.toml")?;Sourcepub fn is_learner(&self) -> bool
pub fn is_learner(&self) -> bool
Checks if this node is configured as a learner (not a voter)
A learner node has role=Learner. Only learners can join via JoinCluster RPC. Voters have role=Follower/Candidate/Leader and are added via config change (AddNode).
Note: Status (Promotable/ReadOnly/Active) is separate from role. This method checks role only.
Trait Implementations§
Source§impl Clone for RaftNodeConfig
impl Clone for RaftNodeConfig
Source§fn clone(&self) -> RaftNodeConfig
fn clone(&self) -> RaftNodeConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RaftNodeConfig
impl Debug for RaftNodeConfig
Source§impl Default for RaftNodeConfig
impl Default for RaftNodeConfig
Source§fn default() -> RaftNodeConfig
fn default() -> RaftNodeConfig
Source§impl<'de> Deserialize<'de> for RaftNodeConfig
impl<'de> Deserialize<'de> for RaftNodeConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for RaftNodeConfig
impl RefUnwindSafe for RaftNodeConfig
impl Send for RaftNodeConfig
impl Sync for RaftNodeConfig
impl Unpin for RaftNodeConfig
impl UnwindSafe for RaftNodeConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request