fix: return the degraded deep-health report instead of raising
The API answers GET /v1/health/deep with 503 and a full report when a dependency is down. _handle_response raised for every status at or above 400, so deep_health() raised exactly when callers need the dependency details. Both the sync and async clients now accept 503 for this endpoint. Claude-Session: https://claude.ai/code/session_01Agoc9bRVE9KL7mmWtey9Vq
This commit is contained in:
1 parent
932a4d3022
commit
b438ead6ae
2 files changed
+10
-4
No files matched your search
@@ -130,9 +130,11 @@ class AsyncElydoraClient:
|
|||||||
headers=build_headers(self.token),
|
headers=build_headers(self.token),
|
||||||
)
|
)
|
||||||
|
|
||||||
async def _get_public(self, path: str) -> Any:
|
async def _get_public(self, path: str, *, accept_status: Optional[int] = None) -> Any:
|
||||||
session = await self._get_session()
|
session = await self._get_session()
|
||||||
async with session.get(f"{self.base_url}{path}", timeout=TIMEOUT) as response:
|
async with session.get(f"{self.base_url}{path}", timeout=TIMEOUT) as response:
|
||||||
|
if accept_status is not None and response.status == accept_status:
|
||||||
|
return await response.json()
|
||||||
return await self._handle_response(response)
|
return await self._handle_response(response)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -349,4 +351,5 @@ class AsyncElydoraClient:
|
|||||||
return await self._get_public("/v1/health")
|
return await self._get_public("/v1/health")
|
||||||
|
|
||||||
async def deep_health(self) -> DeepHealthResponse:
|
async def deep_health(self) -> DeepHealthResponse:
|
||||||
return await self._get_public("/v1/health/deep")
|
"""503 carries the degraded report, not an error."""
|
||||||
|
return await self._get_public("/v1/health/deep", accept_status=503)
|
||||||
+5
-2
@@ -119,8 +119,10 @@ class ElydoraClient:
|
|||||||
headers=build_headers(self.token),
|
headers=build_headers(self.token),
|
||||||
)
|
)
|
||||||
|
|
||||||
def _get_public(self, path: str) -> Any:
|
def _get_public(self, path: str, *, accept_status: Optional[int] = None) -> Any:
|
||||||
response = self._session.get(f"{self.base_url}{path}", timeout=REQUEST_TIMEOUT_SECONDS)
|
response = self._session.get(f"{self.base_url}{path}", timeout=REQUEST_TIMEOUT_SECONDS)
|
||||||
|
if accept_status is not None and response.status_code == accept_status:
|
||||||
|
return response.json()
|
||||||
return self._handle_response(response)
|
return self._handle_response(response)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -324,4 +326,5 @@ class ElydoraClient:
|
|||||||
return self._get_public("/v1/health")
|
return self._get_public("/v1/health")
|
||||||
|
|
||||||
def deep_health(self) -> DeepHealthResponse:
|
def deep_health(self) -> DeepHealthResponse:
|
||||||
return self._get_public("/v1/health/deep")
|
"""503 carries the degraded report, not an error."""
|
||||||
|
return self._get_public("/v1/health/deep", accept_status=503)
|
||||||
Reference in new issue
Block a user