Expand description
Batch processing for multiple HEDL files with parallel execution and progress reporting.
This module provides efficient batch processing capabilities for operations on multiple HEDL files. It uses Rayon for parallel processing when beneficial and provides real-time progress reporting with detailed error tracking.
§Features
- Parallel Processing: Automatic parallelization using Rayon’s work-stealing scheduler
- Progress Reporting: Real-time progress with file counts and success/failure tracking
- Error Resilience: Continues processing on errors, collecting all failures for reporting
- Performance Optimization: Intelligent parallel/serial mode selection based on workload
- Type Safety: Strongly typed operation definitions with compile-time guarantees
§Architecture
The batch processing system uses a functional architecture with:
- Operation trait for extensible batch operations
- Result aggregation with detailed error context
- Atomic counters for thread-safe progress tracking
- Zero-copy file path handling
§Examples
use hedl_cli::batch::{BatchProcessor, BatchConfig, ValidationOperation};
use std::path::PathBuf;
// Create a batch processor with default configuration
let processor = BatchProcessor::new(BatchConfig::default());
// Validate multiple files in parallel
let files = vec![
PathBuf::from("file1.hedl"),
PathBuf::from("file2.hedl"),
PathBuf::from("file3.hedl"),
];
let operation = ValidationOperation { strict: true };
let results = processor.process(&files, operation, true)?;
println!("Processed {} files, {} succeeded, {} failed",
results.total_files(),
results.success_count(),
results.failure_count()
);§Performance Characteristics
- Small batches (< 10 files): Serial processing to avoid overhead
- Medium batches (10-100 files): Parallel with Rayon thread pool
- Large batches (> 100 files): Chunked parallel processing with progress updates
§Thread Safety
All progress tracking uses atomic operations for lock-free concurrent access. Operations are required to be Send + Sync for parallel execution.
Structs§
- Batch
Config - Configuration for batch processing operations.
- Batch
Processor - High-performance batch processor for HEDL files.
- Batch
Results - Aggregated results from a batch processing operation.
- File
Result - Result of processing a single file in a batch operation.
- Format
Operation - Batch format operation.
- Lint
Operation - Batch lint operation.
- Validation
Operation - Batch validation operation.
Traits§
- Batch
Operation - Trait for batch operations on HEDL files.