tcrm-monitor 0.1.7

Task dependency management and execution library with parallel processing, real-time monitoring, and runtime control
docs.rs failed to build tcrm-monitor-0.1.7
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: tcrm-monitor-0.1.3

TCRM Monitor

Task monitor unit for the TCRM project A task dependency management and execution library for Rust applications.

Features

  • Task Dependency Management: Define task dependency graphs with validation
  • Parallel Execution: Execute independent tasks concurrently while respecting dependencies
  • Termination Control: Automatically terminate dependent tasks when dependents finish
  • Event-Driven: Real-time task execution events for monitoring and logging
  • Task Control: Stop, terminate specific tasks, and send stdin input during execution
  • Stdin Support: Send input to tasks with stdin enabled

Installation

Add this to your Cargo.toml:

[dependencies]
tcrm-monitor = { version = "0.1.1" }

Quick Start

use std::collections::HashMap;
use tcrm_monitor::monitor::{TaskMonitor, config::{TaskSpec, TaskShell}};
use tcrm_task::tasks::config::TaskConfig;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut tasks = HashMap::new();
    
    // Define a simple task chain: setup -> build -> test
    tasks.insert(
        "setup".to_string(),
        TaskSpec::new(TaskConfig::new("echo").args(["Setting up..."]))
            .shell(TaskShell::Auto),
    );
    
    tasks.insert(
        "build".to_string(),
        TaskSpec::new(TaskConfig::new("echo").args(["Building..."]))
            .dependencies(["setup"])
            .shell(TaskShell::Auto),
    );
    
    tasks.insert(
        "test".to_string(),
        TaskSpec::new(TaskConfig::new("echo").args(["Testing..."]))
            .dependencies(["build"])
            .shell(TaskShell::Auto),
    );
    
    // Create and execute the task monitor
    let mut monitor = TaskMonitor::new(tasks)?;
    monitor.execute_all_direct(None).await;
    
    Ok(())
}

Examples

See the examples/ directory

Event Monitoring

Monitor task execution with real-time events:

use tokio::sync::mpsc;

let (event_tx, mut event_rx) = mpsc::channel(1024);

// Start monitoring in background
tokio::spawn(async move {
    while let Some(event) = event_rx.recv().await {
        match event {
            TaskEvent::Started { task_name } => {
                println!("Task started: {}", task_name);
            }
            TaskEvent::Ready { task_name } => {
                println!("Task ready: {}", task_name);
            }
            TaskEvent::Stopped { task_name, .. } => {
                println!("Task completed: {}", task_name);
            }
            TaskEvent::Error { task_name, error } => {
                eprintln!("Task failed: {} - {}", task_name, error);
            }
            _ => {}
        }
    }
});

// Execute with event monitoring
monitor.execute_all_direct(Some(event_tx)).await;

License

Licensed under either of

at your option.