ctp-slack-bot / src /ctp_slack_bot /services /application_health_service.py
LiKenun's picture
Refactor #3
bb7c9a3
raw
history blame contribute delete
800 Bytes
from loguru import logger
from pydantic import ConfigDict
from types import MappingProxyType
from typing import Collection, Mapping, Self
from ctp_slack_bot.core import ApplicationComponentBase, HealthReportingApplicationComponentBase
class ApplicationHealthService(ApplicationComponentBase):
"""
Service for checking and reporting application health.
"""
model_config = ConfigDict(frozen=True)
services: list[HealthReportingApplicationComponentBase]
async def get_health(self: Self) -> Mapping[str, bool]:
return MappingProxyType({service.name: await service.is_healthy()
for service
in self.services})
@property
def name(self: Self) -> str:
return "application_health_service"