mirror of
https://github.com/taskgenius/taskgenius-plugin.git
synced 2026-07-22 06:40:25 +00:00
- Change performSearch visibility from private to public - Allow setting.ts to trigger search when navigating from URI
61 lines
No EOL
2.9 KiB
Markdown
61 lines
No EOL
2.9 KiB
Markdown
# Worker Processing Control Implementation
|
|
|
|
## Overview
|
|
Implemented complete control for background worker processing in Task Genius plugin, allowing users to enable/disable worker threads for file parsing performance optimization.
|
|
|
|
## Changes Made
|
|
|
|
### 1. Settings UI Integration (`IndexSettingsTab.ts`)
|
|
- Updated the "Enable worker processing" toggle to use the new `fileSource.performance.enableWorkerProcessing` setting path
|
|
- Added backward compatibility with legacy `fileParsingConfig.enableWorkerProcessing` setting
|
|
- Ensures proper initialization of setting structure when needed
|
|
|
|
### 2. WorkerOrchestrator Enhancement (`WorkerOrchestrator.ts`)
|
|
- Added `enableWorkerProcessing` configuration option to constructor
|
|
- Implemented `setWorkerProcessingEnabled()` method for dynamic control
|
|
- Added `isWorkerProcessingEnabled()` status check method
|
|
- Enhanced `getMetrics()` to provide comprehensive performance statistics
|
|
- Circuit breaker automatically resets when re-enabling workers
|
|
|
|
### 3. DataflowOrchestrator Integration (`Orchestrator.ts`)
|
|
- Reads worker processing setting from both new and legacy paths
|
|
- Passes configuration to WorkerOrchestrator during initialization
|
|
- Added `updateSettings()` method to propagate setting changes
|
|
- Added `getWorkerStatus()` for monitoring worker state and metrics
|
|
|
|
### 4. Settings Update Flow (`setting.ts`)
|
|
- Modified `applySettingsUpdate()` to call `dataflowOrchestrator.updateSettings()`
|
|
- Ensures worker processing changes take effect immediately without restart
|
|
|
|
### 5. FileSource Management (`FileSource.ts`)
|
|
- Added `cleanup()` method for proper resource cleanup
|
|
- Added `updateConfig()` alias for configuration updates
|
|
- Properly handles initialization and cleanup based on settings
|
|
|
|
## How It Works
|
|
|
|
1. **User toggles setting**: User changes "Enable worker processing" in Index Settings
|
|
2. **Setting saved**: New value stored in `fileSource.performance.enableWorkerProcessing`
|
|
3. **Update propagated**: `applySettingsUpdate()` calls `dataflowOrchestrator.updateSettings()`
|
|
4. **Worker control**: `WorkerOrchestrator.setWorkerProcessingEnabled()` updates worker state
|
|
5. **Processing mode**: Tasks are processed either by workers or main thread based on setting
|
|
|
|
## Benefits
|
|
|
|
- **Performance Control**: Users can disable workers if experiencing issues
|
|
- **Dynamic Updates**: Changes take effect immediately without plugin restart
|
|
- **Backward Compatibility**: Works with both old and new setting paths
|
|
- **Circuit Breaker**: Automatic recovery when re-enabling workers
|
|
- **Monitoring**: Comprehensive metrics for debugging and optimization
|
|
|
|
## Testing
|
|
|
|
Created comprehensive test suite (`worker-processing-control.test.ts`) that verifies:
|
|
- Default enabled state
|
|
- Configuration respect on initialization
|
|
- Dynamic enabling/disabling
|
|
- Circuit breaker reset behavior
|
|
- Metrics availability
|
|
- Settings path fallback logic
|
|
|
|
All tests pass successfully, confirming proper implementation. |