Skip to content

Commit

Permalink
Add ScanChunk to allow injecting Chunks into the SourceManager's channel
Browse files Browse the repository at this point in the history
With the introduction of the SourceManager, the chunks channel became
private and read-only. This provides a method to write chunks into the
channel as we transition away from needing to do that.
  • Loading branch information
mcastorina committed Aug 16, 2023
1 parent db89e34 commit d3b8ce4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,13 @@ func (e *Engine) ResultsChan() chan detectors.ResultWithMetadata {
return e.results
}

// ScanChunk injects a chunk into the output stream of chunks to be scanned.
// This method should rarely be used. TODO: Remove when dependencies no longer
// rely on this functionality.
func (e *Engine) ScanChunk(chunk *sources.Chunk) {
e.sourceManager.ScanChunk(chunk)
}

// detectableChunk is a decoded chunk that is ready to be scanned by its detector.
type detectableChunk struct {
detector detectors.Detector
Expand Down
7 changes: 7 additions & 0 deletions pkg/sources/source_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@ func (s *SourceManager) Wait() error {
return s.pool.Wait()
}

// ScanChunk injects a chunk into the output stream of chunks to be scanned.
// This method should rarely be used. TODO: Remove when dependencies no longer
// rely on this functionality.
func (s *SourceManager) ScanChunk(chunk *Chunk) {
s.outputChunks <- chunk
}

// preflightChecks is a helper method to check the Manager or the context isn't
// done and that the handle is valid.
func (s *SourceManager) preflightChecks(ctx context.Context, handle handle) error {
Expand Down

0 comments on commit d3b8ce4

Please sign in to comment.