61 lines
2.3 KiB
Markdown
61 lines
2.3 KiB
Markdown
# Architecture of the `monitor` Crate
|
|
|
|
The `monitor` crate provides a command-line interface for monitoring and managing Rhai task execution across the rhailib ecosystem. It offers real-time visibility into task queues, execution status, and system performance.
|
|
|
|
## Core Architecture
|
|
|
|
```mermaid
|
|
graph TD
|
|
A[Monitor CLI] --> B[Task Monitoring]
|
|
A --> C[Queue Management]
|
|
A --> D[Performance Metrics]
|
|
|
|
B --> B1[Redis Task Tracking]
|
|
B --> B2[Status Visualization]
|
|
B --> B3[Real-time Updates]
|
|
|
|
C --> C1[Queue Inspection]
|
|
C --> C2[Task Management]
|
|
C --> C3[Worker Status]
|
|
|
|
D --> D1[Performance Plotting]
|
|
D --> D2[Metrics Collection]
|
|
D --> D3[Historical Analysis]
|
|
```
|
|
|
|
## Key Components
|
|
|
|
### 1. CLI Logic (`cli_logic.rs`)
|
|
- **Command Processing**: Handles user commands and interface
|
|
- **Real-time Monitoring**: Continuous task status updates
|
|
- **Interactive Interface**: User-friendly command-line experience
|
|
|
|
### 2. Task Management (`tasks.rs`)
|
|
- **Task Discovery**: Finds and tracks tasks across Redis queues
|
|
- **Status Reporting**: Provides detailed task execution information
|
|
- **Queue Analysis**: Monitors queue depths and processing rates
|
|
|
|
### 3. Performance Plotting (`plot.rs`)
|
|
- **Metrics Visualization**: Creates performance charts and graphs
|
|
- **Trend Analysis**: Historical performance tracking
|
|
- **System Health**: Overall system performance indicators
|
|
|
|
## Features
|
|
|
|
- **Real-time Task Monitoring**: Live updates of task execution status
|
|
- **Queue Management**: Inspection and management of Redis task queues
|
|
- **Performance Metrics**: System performance visualization and analysis
|
|
- **Interactive CLI**: User-friendly command-line interface
|
|
- **Multi-worker Support**: Monitoring across multiple worker instances
|
|
|
|
## Dependencies
|
|
|
|
- **Redis Integration**: Direct Redis connectivity for queue monitoring
|
|
- **CLI Framework**: Clap for command-line argument parsing
|
|
- **Async Runtime**: Tokio for asynchronous operations
|
|
- **Visualization**: Pretty tables and terminal clearing for UI
|
|
- **Logging**: Tracing for structured logging and debugging
|
|
|
|
## Usage Patterns
|
|
|
|
The monitor serves as a central observability tool for rhailib deployments, providing operators with comprehensive visibility into system behavior and performance characteristics. |