Implement shared idempotency, health-aware balancing and replica lifecycle checks

This commit is contained in:
2026-11-06 17:58:43 +03:00
parent 0ab3a341aa
commit 029bf9b377
35 changed files with 2470 additions and 20 deletions
+21
View File
@@ -0,0 +1,21 @@
import os
import sys
import time
import urllib.error
import urllib.request
wanted = int(sys.argv[1])
url = "http://127.0.0.1:" + os.environ.get("PUBLIC_PORT", "8083") + "/health/ready"
deadline = time.monotonic() + 40
seen = set()
while time.monotonic() < deadline:
try:
with urllib.request.urlopen(url, timeout=2) as response:
seen.add(response.headers["X-Instance-Id"])
if len(seen) >= wanted:
break
except (urllib.error.URLError, TimeoutError):
seen.clear()
time.sleep(0.1)
else:
raise SystemExit("LB did not expose enough healthy replicas")