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:
@@ -1,13 +1,12 @@
|
||||
"""Quota feature dependencies: get_quota_service."""
|
||||
|
||||
from fastapi import Depends
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.core.db import get_async_db
|
||||
from app.features.quota.service import QuotaService
|
||||
from app.core.deps_types import DbDep
|
||||
|
||||
|
||||
def get_quota_service(
|
||||
db: AsyncSession = Depends(get_async_db),
|
||||
db: DbDep,
|
||||
) -> QuotaService:
|
||||
return QuotaService(db=db)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from app.core.dependencies import get_current_user
|
||||
from app.core.openapi import error_responses
|
||||
from app.features.quota.deps import get_quota_service
|
||||
from app.features.quota.schemas import QuotaCheckResponse
|
||||
from app.features.quota.service import QuotaService
|
||||
@@ -13,12 +14,7 @@ from app.features.user.models import User
|
||||
router = APIRouter(
|
||||
prefix="/api/quota",
|
||||
tags=["quota"],
|
||||
responses={
|
||||
401: {"description": "认证失败"},
|
||||
403: {"description": "权限不足"},
|
||||
404: {"description": "资源不存在"},
|
||||
429: {"description": "配额已用尽"},
|
||||
},
|
||||
responses=error_responses(401, 403, 404, 429),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user