Skip to content

Commit

Permalink
✨ use ephemeral runtimes for discovered assets
Browse files Browse the repository at this point in the history
We were already instantiating new runtimes for every asset that was
discovered. However, until the introduction of ephemeral runtimes, these
had the disadvantage that any runtime that was shut down would also shut
down the plug instance, which is shared.

In this new paradigm, we introduce explicitly ephemeral runtimes, which
are not shared. They have their own plugin instance that can safely be
shut down without impacting other providers.

For more details see: mondoohq/cnquery#2050

Signed-off-by: Dominik Richter <[email protected]>
  • Loading branch information
arlimus committed Oct 3, 2023
1 parent 7a6b20c commit c76a08c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions policy/scan/local_scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func (s *LocalScanner) distributeJob(job *Job, ctx context.Context, upstream *up
for i := range assetCandidates {
candidate := assetCandidates[i]

runtime, err := providers.Coordinator.RuntimeFor(candidate.asset, candidate.runtime)
runtime, err := providers.Coordinator.EphemeralRuntimeFor(candidate.asset)
if err != nil {
return nil, false, err
}
Expand Down Expand Up @@ -419,7 +419,7 @@ func (s *LocalScanner) distributeJob(job *Job, ctx context.Context, upstream *up
runtime: runtime,
})

// we don't need the runtime anymore, so close it
// shut down all ephemeral runtimes
runtime.Close()
}
finished = true
Expand Down

0 comments on commit c76a08c

Please sign in to comment.