Health Check#
- class ccat_data_transfer.health_check.HealthCheck(service_type: str, service_name: str, update_interval: int = 30, ttl: int = 90, redis_client: Redis | None = None)[source]#
Bases:
objectA utility class for service health monitoring using Redis.
This class maintains a heartbeat for services by periodically updating a Redis key with TTL. If a service stops updating its key, it will automatically expire, indicating the service is no longer healthy.
- __init__(service_type: str, service_name: str, update_interval: int = 30, ttl: int = 90, redis_client: Redis | None = None)[source]#
Initialize health check for a service.
- Parameters:
service_type (str) – Type of the service (e.g., ‘data_transfer’, ‘ingestion’)
service_name (str) – Name of the service instance (e.g., ‘manager_cologne’)
update_interval (int) – How often to update the health status (seconds)
ttl (int) – How long the health status remains valid (seconds)
redis_client (redis.Redis, optional) – Custom Redis client instance
- classmethod check_service_health(service_type: str, service_name: str, redis_client: Redis | None = None) bool[source]#
Check if a specific service is healthy.
- Parameters:
service_type (str) – Type of the service to check
service_name (str) – Name of the service to check
redis_client (redis.Redis, optional) – Custom Redis client instance
- Returns:
True if service is healthy, False otherwise
- Return type:
bool
- classmethod check_services_health(service_type: str, redis_client: Redis | None = None) dict[source]#
Check health status of all services of a specific type.
- Parameters:
service_type (str) – Type of services to check
redis_client (redis.Redis, optional) – Custom Redis client instance
- Returns:
Dictionary mapping service names to their health status
- Return type:
dict
Overview#
The Health Check service provides system health monitoring and status reporting.
Key Functions#
check_system_health()- Check overall system healthget_health_status()- Get current health status