fix: 更新main.py逻辑

This commit is contained in:
2026-09-11 10:47:01 +08:00
parent d2a3f024c4
commit 5915319f9f
9 changed files with 66 additions and 8 deletions
+11 -1
View File
@@ -24,6 +24,16 @@ def client() -> AsyncMilvusClient:
return _client
async def ensure_database(milvus_client: AsyncMilvusClient | None = None) -> None:
"""Create the configured project database only when it does not exist."""
target = milvus_client or client()
database_name = settings.milvus.db_name
if not database_name:
raise RuntimeError("MILVUS_DB must be configured")
if database_name not in await target.list_databases():
await target.create_database(database_name)
async def init_db() -> None:
client() # 急切建连;失败由注册表重试(config/database/__init__.py)
@@ -36,4 +46,4 @@ async def dispose() -> None:
async def check_health() -> None:
await client().get_server_version()
await client().get_server_version()