Skip to content

castlecraft_engineer.abstractions.event_consumer

castlecraft_engineer.abstractions.event_consumer

EventStreamConsumer

Bases: ABC

Abstract base class for consuming events from an external stream and publishing them to an internal EventBus.

Source code in src/castlecraft_engineer/abstractions/event_consumer.py
class EventStreamConsumer(ABC):
    """
    Abstract base class for consuming events from an external stream
    and publishing them to an internal EventBus.
    """

    @abstractmethod
    async def run(self):
        """
        Starts the consumer loop to listen for and process events.
        This method should typically run indefinitely
        until shutdown is requested.
        """
        raise NotImplementedError

    @abstractmethod
    async def shutdown(self):
        """
        Initiates a graceful shutdown of the consumer.
        Implementations should ensure pending work is
        handled and resources are released.
        """
        raise NotImplementedError

run() abstractmethod async

Starts the consumer loop to listen for and process events. This method should typically run indefinitely until shutdown is requested.

Source code in src/castlecraft_engineer/abstractions/event_consumer.py
@abstractmethod
async def run(self):
    """
    Starts the consumer loop to listen for and process events.
    This method should typically run indefinitely
    until shutdown is requested.
    """
    raise NotImplementedError

shutdown() abstractmethod async

Initiates a graceful shutdown of the consumer. Implementations should ensure pending work is handled and resources are released.

Source code in src/castlecraft_engineer/abstractions/event_consumer.py
@abstractmethod
async def shutdown(self):
    """
    Initiates a graceful shutdown of the consumer.
    Implementations should ensure pending work is
    handled and resources are released.
    """
    raise NotImplementedError