feat: Refactor HorizonsService to use httpx and system_settings for timeout control

main
mula.liu 2025-12-03 18:31:27 +08:00
parent f228af4e7f
commit 5172ec5d66
1 changed files with 3 additions and 2 deletions

View File

@ -415,7 +415,7 @@ class HorizonsService:
return positions
async def search_body_by_name(self, name: str) -> dict:
async def search_body_by_name(self, name: str, db: AsyncSession) -> dict:
"""
Search for a celestial body by name in NASA Horizons database using httpx.
This method replaces the astroquery-based search to unify proxy and timeout control.
@ -435,7 +435,8 @@ class HorizonsService:
"CENTER": "@ssb" # Search from Solar System Barycenter for consistent object IDs
}
client_kwargs = {"timeout": settings.nasa_api_timeout}
timeout = await self._get_timeout(db)
client_kwargs = {"timeout": timeout}
if settings.proxy_dict:
client_kwargs["proxies"] = settings.proxy_dict