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:
Sully
2026-05-22 13:44:50 +08:00
committed by GitHub
parent f09ae248f9
commit 53e0065e3e
298 changed files with 15247 additions and 4344 deletions

View File

@@ -16,6 +16,8 @@ import httpx
from app.core.config import settings
from app.core.logging import get_logger
from app.features.memoir.constants import memoir
from app.core.runtime_constants import misc_defaults
logger = get_logger(__name__)
@@ -62,7 +64,7 @@ class LiblibImageProvider:
self.access_key = access_key or (settings.liblib_access_key or "")
self.secret_key = secret_key or (settings.liblib_secret_key or "")
self.base_url = (
base_url or settings.liblib_base_url or "https://openapi.liblibai.cloud"
base_url or misc_defaults.liblib_base_url or "https://openapi.liblibai.cloud"
).rstrip("/")
self.template_uuid = template_uuid or (
settings.liblib_template_uuid or DEFAULT_LIBLIB_TEMPLATE_UUID
@@ -240,7 +242,7 @@ def _build_allowed_download_hosts(
if configured_hosts is None:
configured_hosts = tuple(
host.strip().lower()
for host in (settings.memoir_image_download_hosts or "").split(",")
for host in (memoir.image_download_hosts or "").split(",")
if host.strip()
)
base_hostname = (urlparse(base_url).hostname or "").lower()