run_node

Function run_node 

Source
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:

  1. Initializes the node from config
  2. Starts the node with the context
  3. Handles errors

§Arguments

  • config - Node-specific configuration
  • ctx - Execution context
  • health_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(())
}