"""鉴权库连接池""" import asyncpg from .config import settings _pool: asyncpg.Pool | None = None async def get_pool() -> asyncpg.Pool: global _pool if _pool is None: _pool = await asyncpg.create_pool( host=settings.AUTH_DB_HOST, port=settings.AUTH_DB_PORT, user=settings.AUTH_DB_USER, password=settings.AUTH_DB_PASSWORD, database=settings.AUTH_DB_NAME, min_size=2, max_size=10, ) return _pool async def close_pool() -> None: global _pool if _pool is not None: await _pool.close() _pool = None