feat: milvus基本的增删改查
This commit is contained in:
+8
-2
@@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
from fastapi import FastAPI
|
||||
@@ -8,6 +9,7 @@ from starlette.staticfiles import StaticFiles
|
||||
|
||||
from app.middlewares.app_middlewares import add_app_middlewares
|
||||
from app.utils.db_utils import check_database_connection
|
||||
from app.utils.milvus_utils import milvus_service
|
||||
from app.utils.postgres_checkpointer import check_postgres_connection, close_postgres_connection
|
||||
|
||||
|
||||
@@ -15,8 +17,12 @@ def create_app():
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
print("lifespan:启动阶段")
|
||||
async_engine = await check_database_connection()
|
||||
await check_postgres_connection()
|
||||
async_results = await asyncio.gather(
|
||||
asyncio.create_task(check_database_connection()),
|
||||
asyncio.create_task(check_postgres_connection()),
|
||||
asyncio.create_task(milvus_service.check_milvus_connection()),
|
||||
)
|
||||
async_engine = async_results[0]
|
||||
yield
|
||||
print("lifespan:销毁阶段")
|
||||
await async_engine.dispose()
|
||||
|
||||
Reference in New Issue
Block a user