The monitoring service has a method that collects a short summary of worker health from several asynchronous sources. After a recent change, under load some calls stopped completing, and when a single source fails, the final summary started losing data instead of producing a degraded result.
build method must query all provided sources and return Future[HealthSummary]."ok" if the source returned true;"down" if the source returned false;"unknown" if the source completed with an error.healthy field must contain the number of workers with status "ok".scalac WorkerHealthAggregator.scala Main.scala && scala Main
Main:
ExecutionContext;Future with an error.ExecutionContext, the build call must complete and return a summary without hanging."unknown".healthy count must match the number of "ok" statuses in the final map.scalac and execution via scalaExecutionContext.fromExecutor(Executors.newSingleThreadExecutor()) and ExecutionContext.global are usedUse line comments to explain the problem, its impact, the fix and how to test it.