hflow
hflow is a lightweight, thread-safe task orchestration library for Rust CLI applications. It provides a hierarchical structure to manage and visualize sequential task groups with real-time feedback.
Features
- Thread-Safe Execution: Utilizes atomic-like synchronization using
Arc<Mutex<T>>for state management across threads. - Hierarchical Task Management: Organizes work into
ExecutionUnit,TaskGroup, andProgressManagerfor granular control. - Real-time Visual Feedback: Built-in terminal spinner and status indicators with ANSI escape sequences for line clearing.
- Automatic Error Handling: Integrated process termination on unit failure to ensure system integrity during critical deployments.
Architecture
The library follows a three-tier hierarchy:
- ProgressManager: The top-level orchestrator that manages multiple groups.
- TaskGroup: A collection of units that are executed sequentially within the group's context.
- ExecutionUnit: The atomic unit of work that executes a provided closure in a dedicated background thread.
Installation
Add the following to your Cargo.toml:
[]
= { = "https://github.com/cvalendb/hflow" }
= "2.1"
Usage Example
The following example demonstrates how to set up a multi-stage deployment process:
use ;
use thread;
use Duration;
Technical Specifications
- Concurrency Model: Each
ExecutionUnitspawns a standard thread for non-blocking logic execution. - Terminal UI: Refresh rate is set to 100ms to balance visual fluidity and CPU overhead.
- State Management: Uses
Option::take()to move closures safely into threads without compromising struct integrity. ? Es ideal para presentar en un portafolio o en el repositorio de hsupport. Si necesitas que agregue una sección de "Troubleshooting" o "Contributing", me dices.