docscanner/internal/scanner/workerpool.go
- Workers are isolated: each goroutine reads file paths from the
fileschannel and processes them independently. - Analyzer logic is injected: the worker pool only depends on the
Analyzerinterface. - Extensible: adding a new analyzer is just appending to the
analyzersslice inmain.go. - Proper synchronization: a
sync.WaitGrouptracks worker lifetimes; results are written to a sharedresultschannel.
- Spawn
numWorkersgoroutines. - For each incoming file path:
- Read file contents with
os.ReadFile. - Find the first analyzer whose
Supportsmethod returns true. - Call
Analyze; if it returns a non-nil result and no error, send it toresults.
- Read file contents with
The worker pool does not know about directory structure or JSON output; it focuses purely on concurrent analysis.