Source code for sqlspec.extensions.events._protocols

"""Protocols for EventChannel handlers and backends."""

from typing import TYPE_CHECKING, Any, ClassVar, Protocol, runtime_checkable

if TYPE_CHECKING:
    from collections.abc import Sequence

    from sqlspec.extensions.events._models import EventMessage

__all__ = ("AsyncEventBackendProtocol", "AsyncEventHandler", "SyncEventBackendProtocol", "SyncEventHandler")


class AsyncEventHandler(Protocol):
    """Protocol describing async event handler callables."""

    async def __call__(self, message: "EventMessage") -> Any:  # pragma: no cover
        """Process a queued event message asynchronously."""