component-detection icon indicating copy to clipboard operation
component-detection copied to clipboard

Remove Observables and switch to Channels

Open melotic opened this issue 2 years ago • 0 comments

Our current implementation for scanning files/directories is done by using observables:

https://github.com/microsoft/component-detection/blob/29e89522bb3c243be4aa8e188ce2b8c57e96420b/src/Microsoft.ComponentDetection.Common/FastDirectoryWalkerFactory.cs#L32

Instead, we should architect a channel system that works as:

  1. Create a new Task & Channel for each detector
  2. Launch each detector with a semphore blocking execution untill all detectors have subscribed to the channel
  3. Begin scanning directories
  4. Each file found will get sent through the channel
  5. Detector gets the message, and scans file or ignores it depending on the pattern

We could also implement a Broadcast channel similar to https://docs.rs/tokio/latest/tokio/sync/index.html#broadcast-channel

AB#2102424

melotic avatar Sep 06 '23 22:09 melotic