Crate mecha10_core

Crate mecha10_core 

Source
Expand description

Mecha10 Core Runtime

This crate provides the foundational runtime for the Mecha10 framework, including node lifecycle management, health monitoring, and orchestration.

§Features

  • Node lifecycle management (start, stop, restart)
  • Health monitoring and automatic recovery
  • Process management for node execution
  • Integration with config and messaging systems
  • Graceful shutdown handling
  • Type-safe topics system
  • Comprehensive error handling
  • Shared message types

§Quick Start

use mecha10::prelude::*;

#[derive(Node)]
#[subscribe(topics::sensor::CAMERA_RGB)]
#[publish(topics::perception::DETECTIONS)]
struct MyNode {
    config: MyConfig,
}

#[derive(Config)]
struct MyConfig {
    #[validate(range = "0.0..=1.0")]
    threshold: f32,
}

#[async_trait]
impl NodeImpl for MyNode {
    type Config = MyConfig;

    async fn init(config: Self::Config) -> Result<Self> {
        Ok(Self { config })
    }

    async fn run(&mut self, ctx: &Context) -> Result<()> {
        let mut images = ctx.subscribe(topics::sensor::CAMERA_RGB).await?;

        while let Some(image) = images.recv().await {
            // Process image
            ctx.publish(&result).await?;
        }

        Ok(())
    }
}

Re-exports§

pub use context::Context;
pub use context::Receiver;
pub use error::Mecha10Error;
pub use error::Result;
pub use messages::Message;
pub use types::*;

Modules§

actuator
Shared actuator message types
aggregated
Aggregated Topics - Multi-topic subscription with pattern matching
auth
Authorization and Access Control
behavior_interrupt
Behavior Interrupt Trigger
circuit_breaker
Circuit Breaker Pattern for Fault Tolerance
config
config_watcher
Configuration Hot-Reload Support
context
Node execution context
dead_letter
Dead Letter Queue (DLQ) for Failed Message Processing
dependency
Dependency Resolution for Node Startup/Shutdown Ordering
discovery
Service Discovery
error
health
Centralized Health Monitoring
lifecycle
Lifecycle event schemas for mode-based node management
macros
Mecha10 Framework Macros
messages
metrics
Metrics Collection
model
Model configuration utilities for AI nodes
node
prelude
priority_queue
Priority queue for message processing
profiling
Performance Profiling Helpers
publish
Conditional publishing for declarative message publishing
rate_limit
Rate Limiting
recorder
Bag File Recording and Replay (ROS bag-like)
recovery
Graceful Degradation and Automatic Recovery Policies
redis_bridge
Redis Bridge
rpc
Request/Response (RPC) Pattern
rpc_breaker
RPC with Circuit Breaker Integration
rpc_streaming
Streaming RPC for Long-Running Operations
schema
Schema Registry
schema_validation
JSON Schema Validation for Mecha10 Configuration
secrets
Secrets Management
sensor
Shared sensor message types
service
Service Pattern for Infrastructure Components
service_manager
Service Manager for Lifecycle Management
state
Persistent State Storage Abstraction for Nodes
stream
Stream combinators for declarative message processing
teleop
Teleoperation message types
topic_registry
Topic Registry for Runtime Introspection and Validation
topic_utils
Topic utility functions
topics
Type-Safe Topics System
tracing_otel
Distributed Tracing with OpenTelemetry
types
Core type definitions shared across the Mecha10 framework

Macros§

in_node_context
Macro to execute code within a node’s logging context
run_node_simple
Run a node with automatic config loading and context creation
run_node_with_instance
Run a node with instance support for multi-instance deployments
topic_group
Macro to define topic groups

Structs§

Runtime
Runtime orchestrator for managing nodes

Enums§

RuntimeError
Core runtime errors

Type Aliases§

RuntimeResult
Result type for runtime operations