maple.utils.health.HealthMonitor.register
- HealthMonitor.register(container_id: str, name: str, check_fn: Callable[[], bool], restart_fn: Callable[[], None] | None = None, auto_restart: bool = False, max_failures: int = 3) None
Register a container for health monitoring.
Adds a container to the monitoring registry. The container will be checked periodically according to check_interval once the monitor is started. Thread-safe and can be called while monitor is running.
- Parameters:
container_id – Docker container ID to monitor.
name – Policy/Env instance name for logging and status reports.
check_fn – Callable that returns True if container is healthy, False otherwise. Should not raise exceptions.
restart_fn – Optional callable to restart the container when unhealthy. Only used if auto_restart is True.
auto_restart – If True, automatically call restart_fn when container becomes unhealthy.
max_failures – Number of consecutive health check failures before marking container as unhealthy.