from __future__ import annotations

from abc import ABC, abstractmethod


class Monitor(ABC):
    """Base class for long-running background monitors.

    Unlike checks (one-shot, APScheduler-driven), monitors maintain
    persistent state — connections, subscriptions, background tasks.
    """

    @abstractmethod
    async def start(self) -> None:
        """Spawn background task(s). Idempotent if already started."""

    @abstractmethod
    async def stop(self) -> None:
        """Cancel background tasks and wait for cleanup."""

    @property
    @abstractmethod
    def is_healthy(self) -> bool:
        """True when the monitor is running and its connection is live."""
