| Crates.io | tcrm-monitor |
| lib.rs | tcrm-monitor |
| version | 0.1.8 |
| created_at | 2025-09-11 11:33:49.748722+00 |
| updated_at | 2025-09-24 08:05:08.906336+00 |
| description | Task dependency management and execution library with parallel processing, real-time monitoring, and runtime control |
| homepage | https://github.com/xpcn2015/tcrm-monitor |
| repository | https://github.com/xpcn2015/tcrm-monitor |
| max_upload_size | |
| id | 1833694 |
| size | 576,029 |
Task monitor unit for the TCRM project A task dependency management and execution library for Rust applications.
Add this to your Cargo.toml:
[dependencies]
tcrm-monitor = { version = "0.1.1" }
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(())
}
See the examples/ directory
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;
Licensed under either of
at your option.