Files
Hotel-Booking/Backend/venv/lib/python3.12/site-packages/safety/events/handlers/base.py
Iliyan Angelov 62c1fe5951 updates
2025-12-01 06:50:10 +02:00

33 lines
701 B
Python

"""
Event handler definitions for the event bus system.
"""
from abc import ABC, abstractmethod
from typing import Any, TypeVar, Generic
from safety_schemas.models.events import Event
# Type variable for event types
EventType = TypeVar("EventType", bound=Event)
class EventHandler(Generic[EventType], ABC):
"""
Abstract base class for event handlers.
Concrete handlers should implement the handle method.
"""
@abstractmethod
async def handle(self, event: EventType) -> Any:
"""
Handle an event asynchronously.
Args:
event: The event to handle
Returns:
Any result from handling the event
"""
pass