Files
DataRush/services/backend/integrations/checker/healthcheck.py
T
2025-03-02 20:48:21 +03:00

23 lines
693 B
Python

from http import HTTPStatus as status
import httpx
from django.conf import settings
from health_check.backends import BaseHealthCheckBackend
class CheckerHealthCheck(BaseHealthCheckBackend):
critical_service = False
def check_status(self) -> None:
try:
response = httpx.get(
f"{settings.CHECKER_API_ENDPOINT}/health", timeout=10
)
if response.status_code >= status.INTERNAL_SERVER_ERROR:
self.add_error("Checker service is unaccessible")
except httpx.HTTPError:
self.add_error("Checker service is unaccessible")
def identifier(self) -> str:
return self.__class__.__name__