You've already forked Promocode-API
mirror of
https://github.com/devitq/Promocode-API.git
synced 2026-05-22 23:17:10 +00:00
feat: added antifraud healthcheck
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
from http import HTTPStatus as status
|
||||
|
||||
import httpx
|
||||
from django.conf import settings
|
||||
from health_check.backends import BaseHealthCheckBackend
|
||||
|
||||
|
||||
class AntifraudHealthcheck(BaseHealthCheckBackend):
|
||||
critical_service = False
|
||||
|
||||
def check_status(self) -> None:
|
||||
try:
|
||||
response = httpx.get(f"{settings.ANTIFRAUD_ENDPOINT}/api/ping")
|
||||
if response.status_code >= status.INTERNAL_SERVER_ERROR:
|
||||
self.add_error("Antifraud service is unaccessible")
|
||||
except httpx.HTTPError:
|
||||
self.add_error("Antifraud service is unaccessible")
|
||||
|
||||
def identifier(self) -> str:
|
||||
return self.__class__.__name__
|
||||
|
||||
|
||||
__all__ = ["AntifraudHealthcheck"]
|
||||
Reference in New Issue
Block a user