refactor(api): TOML 配置 SSOT、统一错误契约、Auth/事务加固与可观测性 (#33)
配置 SSOT(TOML + .env) 统一错误契约 Auth 与事务边界 Redis / Celery 可靠性:业务 Redis(DB/0)与 Celery broker/backend(DB/1)显式拆分;连接池、sync client 可观测性(OpenTelemetry + LGTM)
This commit is contained in:
@@ -15,6 +15,7 @@ from sqlalchemy.exc import OperationalError
|
||||
|
||||
from app.core.config import settings
|
||||
from app.core.logging import get_logger
|
||||
from app.core.runtime_constants import alembic_defaults
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
@@ -70,12 +71,12 @@ def run_alembic_upgrade_at_startup() -> None:
|
||||
在 asyncio 中请使用 ``asyncio.to_thread(run_alembic_upgrade_at_startup)``,
|
||||
避免阻塞事件循环。
|
||||
"""
|
||||
if not settings.alembic_run_on_startup:
|
||||
if not alembic_defaults.run_on_startup:
|
||||
logger.info("跳过 Alembic 迁移(alembic_run_on_startup=False)")
|
||||
return
|
||||
|
||||
max_tries = max(1, settings.alembic_startup_max_retries)
|
||||
base_delay = float(settings.alembic_startup_retry_base_seconds)
|
||||
max_tries = max(1, alembic_defaults.max_retries)
|
||||
base_delay = float(alembic_defaults.retry_base_seconds)
|
||||
last: BaseException | None = None
|
||||
|
||||
for attempt in range(max_tries):
|
||||
|
||||
Reference in New Issue
Block a user