python_cqrs_dispatcher.registry =============================== .. py:module:: python_cqrs_dispatcher.registry .. autoapi-nested-parse:: Handler registry helpers for bulk and auto registration. Functions --------- .. autoapisummary:: python_cqrs_dispatcher.registry.register_handlers python_cqrs_dispatcher.registry.auto_register_handlers Module Contents --------------- .. py:function:: register_handlers(dispatcher: python_cqrs_dispatcher.dispatcher.CQRSDispatcher, handlers: List[Tuple[Type, Any]]) -> None Bulk register command and query handlers. Args: dispatcher: CQRSDispatcher instance handlers: List of (request_type, handler) tuples Raises: ValueError: If request type is neither command nor query Example: >>> handlers = [ ... (CreateUserCommand, CreateUserHandler()), ... (GetUserQuery, GetUserHandler()), ... ] >>> register_handlers(dispatcher, handlers) .. py:function:: auto_register_handlers(dispatcher: python_cqrs_dispatcher.dispatcher.CQRSDispatcher, module) -> None Auto-discover and register handlers from module. Scans module for handler classes and registers them automatically. Handlers must implement ICommandHandler or IQueryHandler. Args: dispatcher: CQRSDispatcher instance module: Python module to scan Example: >>> import my_app.handlers as handlers_module >>> auto_register_handlers(dispatcher, handlers_module)