pub struct NodeConfig {
pub tick_interval: Duration,
pub max_packet_buffer: usize,
pub max_outgoing_buffer: usize,
pub max_local_events: usize,
pub metrics: Option<NodeMetrics>,
pub observability: Option<ObservabilityConfig>,
pub health_checks: Option<HealthCheckConfig>,
}Expand description
ELARA Node configuration
§Observability
The observability field provides unified configuration for all observability
components (logging, tracing, metrics). It is optional and disabled by default.
When enabled, observability components are initialized before the node starts:
- Logging: Structured logs with configurable format and output
- Tracing: Distributed tracing with OpenTelemetry support
- Metrics Server: HTTP server exposing Prometheus metrics
§Example with Observability
use elara_runtime::node::NodeConfig;
use elara_runtime::observability::{
ObservabilityConfig, LoggingConfig, LogLevel, LogFormat, LogOutput,
MetricsServerConfig
};
use std::time::Duration;
let config = NodeConfig {
tick_interval: Duration::from_millis(100),
max_packet_buffer: 1000,
max_outgoing_buffer: 1000,
max_local_events: 1000,
metrics: None,
observability: Some(ObservabilityConfig {
logging: Some(LoggingConfig {
level: LogLevel::Info,
format: LogFormat::Json,
output: LogOutput::Stdout,
}),
tracing: None,
metrics_server: Some(MetricsServerConfig {
bind_address: "0.0.0.0".to_string(),
port: 9090,
}),
}),
};§Example without Observability (Default)
use elara_runtime::node::NodeConfig;
use std::time::Duration;
let config = NodeConfig {
tick_interval: Duration::from_millis(100),
max_packet_buffer: 1000,
max_outgoing_buffer: 1000,
max_local_events: 1000,
metrics: None,
observability: None, // Observability disabled
};Fields§
§tick_interval: DurationTick interval
max_packet_buffer: usizeMaximum incoming packet buffer
max_outgoing_buffer: usizeMaximum outgoing packet buffer
max_local_events: usize§metrics: Option<NodeMetrics>Optional metrics for monitoring (None = metrics disabled)
observability: Option<ObservabilityConfig>Optional unified observability configuration (None = observability disabled)
When set, this enables structured logging, distributed tracing, and/or
metrics server based on the provided configuration. All components are
opt-in - set individual fields to None to disable specific components.
Note: This is separate from the metrics field. The metrics field
provides direct access to metrics for the node runtime, while observability
provides a unified initialization system with HTTP server support.
health_checks: Option<HealthCheckConfig>Optional health check configuration (None = health checks disabled)
When set, this enables the health check system with built-in checks for:
- Connection health (minimum active connections)
- Memory usage (maximum memory threshold)
- Time drift (maximum drift from network consensus)
- State divergence (maximum pending events)
Health checks are opt-in and disabled by default. When enabled, you can configure thresholds for each check and optionally expose HTTP endpoints for Kubernetes probes and load balancers.
§Example
use elara_runtime::node::NodeConfig;
use elara_runtime::health::HealthCheckConfig;
use std::time::Duration;
let config = NodeConfig {
health_checks: Some(HealthCheckConfig::medium_deployment()),
..Default::default()
};§Production Deployment
Use the preset configurations for common deployment sizes:
HealthCheckConfig::small_deployment()- 10 nodesHealthCheckConfig::medium_deployment()- 100 nodesHealthCheckConfig::large_deployment()- 1000 nodes
Or customize thresholds based on your specific requirements:
use elara_runtime::health::HealthCheckConfig;
use std::time::Duration;
let health_config = HealthCheckConfig {
enabled: true,
server_bind_address: Some("0.0.0.0:8080".parse().unwrap()),
cache_ttl: Duration::from_secs(30),
min_connections: Some(5),
max_memory_mb: Some(2000),
max_time_drift_ms: Some(100),
max_pending_events: Some(1000),
};Implementations§
Source§impl NodeConfig
impl NodeConfig
Sourcepub fn init_health_checks(
&self,
node: Arc<Node>,
) -> Option<(Arc<HealthChecker>, Option<JoinHandle<Result<(), Error>>>)>
pub fn init_health_checks( &self, node: Arc<Node>, ) -> Option<(Arc<HealthChecker>, Option<JoinHandle<Result<(), Error>>>)>
Initializes health checks based on the configuration.
This method creates a HealthChecker with the configured checks and
optionally starts an HTTP server to expose health endpoints.
§Arguments
node- Arc reference to the Node for health checks that need node access
§Returns
Returns Some((checker, server_handle)) if health checks are enabled, where:
checkeris the configuredHealthCheckerserver_handleisSome(JoinHandle)if HTTP server is started,Noneotherwise
Returns None if health checks are disabled.
§Example
use elara_runtime::node::{Node, NodeConfig};
use elara_runtime::health::HealthCheckConfig;
use std::sync::Arc;
let config = NodeConfig {
health_checks: Some(HealthCheckConfig::medium_deployment()),
..Default::default()
};
let node = Arc::new(Node::with_config(config.clone()));
if let Some((checker, server_handle)) = config.init_health_checks(node) {
println!("Health checks initialized");
// Check health programmatically
let status = checker.check_health();
println!("Health status: {:?}", status.overall);
// Server is running in background (if configured)
if let Some(handle) = server_handle {
// Server will run until handle is dropped or joined
}
}§HTTP Endpoints
When server_bind_address is configured, the following endpoints are exposed:
-
GET /health- Overall health status- Returns 200 OK if healthy or degraded
- Returns 503 Service Unavailable if unhealthy
-
GET /ready- Readiness probe (Kubernetes)- Returns 200 OK if healthy or degraded
- Returns 503 Service Unavailable if unhealthy
-
GET /live- Liveness probe (Kubernetes)- Returns 200 OK if healthy or degraded
- Returns 503 Service Unavailable if unhealthy
§Panics
Panics if the health check configuration is invalid (fails validation).
Trait Implementations§
Source§impl Clone for NodeConfig
impl Clone for NodeConfig
Source§fn clone(&self) -> NodeConfig
fn clone(&self) -> NodeConfig
1.0.0 · 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
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> 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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> 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