from app.checks import load_check_module async def run_checks(service_cfg): context = { "base_url": service_cfg.get("base_url") } results = {} executed = [] healthy = True checks = service_cfg["checks"] # index theo name check_map = {c["name"]: c for c in checks} for check in checks: name = check["name"] deps = check.get("depends_on", []) # ---------- CHECK DEPENDENCY ---------- unmet = [ d for d in deps if d not in results or results[d]["ok"] is False ] if unmet: results[name] = { "name": name, "type": check["type"], "ok": False, "skipped": True, "reason": f"depends_on failed: {unmet}", } healthy = False continue # ---------- RUN CHECK ---------- module = load_check_module(check["type"]) result = await module.run(check, context) results[name] = result executed.append(name) if not result["ok"]: healthy = False return healthy, list(results.values())