M5: hardening — retries, per-domain rate limiting, resource limits, docs
- renderer: per-domain politeness limiter (Redis fixed window, in-memory fallback; over-limit requests wait bounded, 429 past deadline); render retry with DNS-failure fast-fail - orchestrator: one retry on connection-level stage failures (not timeouts) - compose: per-container CPU/memory limits; all hardening knobs env-driven and documented in .env.example - README: quick start, MCP + REST usage, architecture, config, dev workflow Verified: rate limit window enforced (3rd request waited for reset), full scrape + MCP web_search smoke green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
a70a6b5f5f
commit
64ffeabd49
7 changed files with 212 additions and 10 deletions
|
|
@ -38,10 +38,18 @@ class StageError(Exception):
|
|||
|
||||
|
||||
async def _post(client: httpx.AsyncClient, url: str, payload: dict, stage: str) -> dict:
|
||||
try:
|
||||
resp = await client.post(url, json=payload, timeout=config.STAGE_TIMEOUT_S)
|
||||
except httpx.HTTPError as exc:
|
||||
raise StageError(stage, f"unreachable: {exc}") from exc
|
||||
# One retry on connection-level failures (service restarting, transient net);
|
||||
# timeouts and HTTP errors are not retried — the work itself likely failed.
|
||||
for attempt in range(2):
|
||||
try:
|
||||
resp = await client.post(url, json=payload, timeout=config.STAGE_TIMEOUT_S)
|
||||
break
|
||||
except (httpx.ConnectError, httpx.ConnectTimeout) as exc:
|
||||
if attempt == 1:
|
||||
raise StageError(stage, f"unreachable: {exc}") from exc
|
||||
await asyncio.sleep(0.5)
|
||||
except httpx.HTTPError as exc:
|
||||
raise StageError(stage, f"unreachable: {exc}") from exc
|
||||
if resp.status_code != 200:
|
||||
detail = resp.text[:500]
|
||||
raise StageError(stage, f"HTTP {resp.status_code}: {detail}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue