The performance of discovery is pretty slow as it is a serial process for all available resources.
The improvements I see are:
Parallelize discovery by type
Initial filtering of discovered resources. If all data for filtering exists on the resources then apply the filter and take the result.
If all data for filtering is not available then include the result for later processing.
Parallelize updating of resource state by using a worker pool which handles resources after 2.
Final filtering of discovered resources, this time with state
Collect all results from 4. and return them as the result from List()
The performance of discovery is pretty slow as it is a serial process for all available resources.
The improvements I see are: