pub async fn run_node<T: NodeImpl>(
config: T::Config,
ctx: Context,
health_config: HealthReportingConfig,
) -> Result<()>Expand description
Run a node with the given configuration and context.
This is a convenience function that:
- Initializes the node from config
- Starts the node with the context
- Handles errors
§Arguments
config- Node-specific configurationctx- Execution contexthealth_config- Health reporting configuration
§Example
use mecha10::prelude::*;
#[tokio::main]
async fn main() -> Result<()> {
let config = MyConfig { rate: 10.0 };
let ctx = Context::new("my_node");
// Use default health reporting (Normal priority, 5s interval)
run_node::<MyNode>(config, ctx, HealthReportingConfig::default()).await?;
// Critical priority for safety-critical nodes (1s interval)
run_node::<MyNode>(config, ctx, HealthReportingConfig::critical()).await?;
// Background priority for auxiliary nodes (30s interval)
run_node::<MyNode>(config, ctx, HealthReportingConfig::background()).await?;
Ok(())
}