pub struct NodeConfig {
pub bind_addr: String,
pub node_id: u64,
pub peers: Vec<String>,
pub heartbeat_interval_ms: u64,
pub election_timeout_ms: u64,
pub compaction_threshold: usize,
pub data_dir: Option<PathBuf>,
pub metrics_addr: String,
pub key_rotation_interval_secs: Option<u64>,
pub key_retention_count: usize,
}Expand description
Full cluster node configuration.
Can be loaded from a TOML file with NodeConfig::load or from a TOML
string with NodeConfig::from_toml. After loading, call
NodeConfig::apply_env_overrides to layer environment variable
overrides on top.
§Field restart requirements
| Field | Hot-reloadable |
|---|---|
heartbeat_interval_ms | Yes (via DynamicConfig) |
compaction_threshold | Yes (via DynamicConfig) |
| All other fields | No — requires restart |
Fields§
§bind_addr: StringBind address for Raft RPC server (e.g. "0.0.0.0:7001").
node_id: u64Node ID — must be unique across the cluster and > 0.
peers: Vec<String>Peer addresses as "node_id=addr" strings, e.g. ["2=10.0.0.2:7001"].
heartbeat_interval_ms: u64Raft heartbeat interval in milliseconds (default 150).
Hot-reloadable.
election_timeout_ms: u64Raft election timeout in milliseconds (default 300).
Must be >= 2 * heartbeat_interval_ms. Requires restart to change.
compaction_threshold: usizeLog compaction threshold: number of entries before triggering a snapshot (default 10 000).
Hot-reloadable.
data_dir: Option<PathBuf>Data directory for Raft log persistence. None disables persistence.
metrics_addr: StringMetrics HTTP endpoint address (default "0.0.0.0:9091").
Requires restart to change.
key_rotation_interval_secs: Option<u64>Optional automatic-rotation interval for the log-encryption master
key, in seconds. None disables time-based rotation; rotation can
still be triggered manually via crate::key_rotation::KeyManager::rotate.
The background tokio task that drives time-based rotation is deferred to a future cycle; this field reserves the configuration surface for when it lands.
key_retention_count: usizeNumber of crate::key_rotation::KeyVersions the
crate::key_rotation::KeyManager retains in its history (current
and previous keys). Default 3. Lower values reclaim memory faster
at the cost of decrypting fewer historical entries after rotation.
Implementations§
Source§impl NodeConfig
impl NodeConfig
Sourcepub fn load(path: &Path) -> Result<Self, ConfigError>
pub fn load(path: &Path) -> Result<Self, ConfigError>
Load from a TOML file, then layer environment variable overrides.
Env vars override individual fields:
| Env var | Field |
|---|---|
AMATERS_BIND_ADDR | bind_addr |
AMATERS_NODE_ID | node_id |
AMATERS_PEERS | peers (comma-separated id=addr pairs) |
AMATERS_HEARTBEAT_INTERVAL_MS | heartbeat_interval_ms |
AMATERS_ELECTION_TIMEOUT_MS | election_timeout_ms |
AMATERS_COMPACTION_THRESHOLD | compaction_threshold |
AMATERS_DATA_DIR | data_dir |
AMATERS_METRICS_ADDR | metrics_addr |
Sourcepub fn from_toml(toml_str: &str) -> Result<Self, ConfigError>
pub fn from_toml(toml_str: &str) -> Result<Self, ConfigError>
Parse from a TOML string directly.
Useful in tests and when the configuration is provided via a
secret store rather than a file on disk. Does not apply env
overrides; call apply_env_overrides if
you also want those.
Sourcepub fn apply_env_overrides(&mut self)
pub fn apply_env_overrides(&mut self)
Apply environment variable overrides from the current process environment.
Unset variables leave the corresponding field unchanged.
Sourcepub fn dynamic(&self) -> DynamicConfig
pub fn dynamic(&self) -> DynamicConfig
Extract the hot-reloadable subset of this configuration.
The returned DynamicConfig can be stored in an
Arc<parking_lot::RwLock<DynamicConfig>> and updated in place when
the configuration is reloaded (e.g. on SIGHUP or via an admin RPC)
without restarting the node.
Sourcepub fn validate(&self) -> Vec<ConfigError>
pub fn validate(&self) -> Vec<ConfigError>
Validate configuration fields.
Returns a list of ConfigError::Validation variants describing each
detected problem. An empty return value means the configuration is
valid.
Trait Implementations§
Source§impl Clone for NodeConfig
impl Clone for NodeConfig
Source§fn clone(&self) -> NodeConfig
fn clone(&self) -> NodeConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NodeConfig
impl Debug for NodeConfig
Source§impl<'de> Deserialize<'de> for NodeConfig
impl<'de> Deserialize<'de> for NodeConfig
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 NodeConfig
impl RefUnwindSafe for NodeConfig
impl Send for NodeConfig
impl Sync for NodeConfig
impl Unpin for NodeConfig
impl UnsafeUnpin for NodeConfig
impl UnwindSafe for NodeConfig
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<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.