Refactor backend: fix geo cache cleanup, scheduler heartbeat, correlation middleware; update docs

This commit is contained in:
2026-05-03 16:02:40 +02:00
parent 896751ada9
commit 5058a50143
9 changed files with 287 additions and 146 deletions

View File

@@ -114,7 +114,13 @@ def register(app: FastAPI) -> None:
``app.state.scheduler`` will receive the job.
"""
settings = get_effective_settings(app)
app.state.scheduler.add_job(
scheduler = getattr(app.state, "scheduler", None)
if scheduler is None:
# In tests or standalone usage, scheduler may not be on app.state yet.
# Use a no-op fallback — the heartbeat won't be registered but no crash.
log.warning("geo_cache_cleanup_no_scheduler")
return
scheduler.add_job(
_run_cleanup_with_resources,
trigger="interval",
seconds=GEO_CLEANUP_INTERVAL,