python_cqrs_dispatcher.registry¶
Handler registry helpers for bulk and auto registration.
Functions¶
|
Bulk register command and query handlers. |
|
Auto-discover and register handlers from module. |
Module Contents¶
- python_cqrs_dispatcher.registry.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)
- python_cqrs_dispatcher.registry.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)