Skip to main content

mecha10_runtime/
node.rs

1//! Node runner trait and types
2
3use crate::health::HealthStatus;
4use anyhow::Result;
5use async_trait::async_trait;
6
7#[async_trait]
8pub trait NodeRunner: Send + Sync {
9    /// Get the node name
10    fn name(&self) -> &str;
11
12    /// Run the node
13    async fn run(&mut self) -> Result<()>;
14
15    /// Perform a health check
16    ///
17    /// Override this method to provide custom health checking logic.
18    /// By default, nodes are considered healthy.
19    async fn health_check(&self) -> HealthStatus {
20        HealthStatus::Healthy
21    }
22
23    /// Handle shutdown signal
24    ///
25    /// Override this method to perform cleanup before shutdown.
26    /// By default, no special cleanup is performed.
27    async fn shutdown(&mut self) -> Result<()> {
28        Ok(())
29    }
30}