fix: 更新main.py逻辑
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user