Separate bootstrap settings from runtime overrides with a dedicated runtime settings manager

This commit is contained in:
2026-04-10 19:31:51 +02:00
parent 9b4cd17e3b
commit 3b6e39ddad
11 changed files with 61 additions and 32 deletions

View File

@@ -20,7 +20,7 @@ from app.config import Settings
from app.models.auth import Session
from app.models.config import PendingRecovery
from app.models.server import ServerStatus
from app.utils.runtime_state import RuntimeState
from app.utils.runtime_state import RuntimeState, get_effective_settings
from app.utils.session_cache import SessionCache
log: structlog.stdlib.BoundLogger = structlog.get_logger()
@@ -35,6 +35,7 @@ class AppState(Protocol):
server_status: ServerStatus
pending_recovery: PendingRecovery | None
last_activation: dict[str, datetime.datetime] | None
runtime_settings: Settings | None
runtime_state: RuntimeState
session_cache: SessionCache
@@ -90,16 +91,8 @@ async def get_db(request: Request) -> AsyncGenerator[aiosqlite.Connection, None]
async def get_settings(request: Request) -> Settings:
"""Provide the :class:`~app.config.Settings` instance from ``app.state``.
Args:
request: The current FastAPI request (injected automatically).
Returns:
The application settings loaded at startup.
"""
state = cast("AppState", request.app.state)
return state.settings
"""Provide the effective application settings for the current request."""
return get_effective_settings(request.app)
async def get_http_session(request: Request) -> aiohttp.ClientSession: