Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Indroic/HexCore/llms.txt
Use this file to discover all available pages before exploring further.
HandlerRegistry is the central directory that connects message types to their handlers. You register handlers once at startup (or via a DI container factory), and the buses look up the correct handler at dispatch time. The registry supports two registration strategies: eager (pass a handler instance directly) and lazy (pass a zero-argument factory callable that is invoked on first use and then cached). A fluent API lets you chain register_* calls on a single registry instance.
Constructor
When
False (the default), registering a second handler for the same command or query type raises DuplicateHandlerError. Set to True to allow handler replacement — useful for testing where you want to swap handlers without rebuilding the registry.Type aliases
A zero-argument callable that returns a command handler instance. Used for lazy/DI-container registration.
A zero-argument callable that returns a query handler instance. Used for lazy/DI-container registration.
Command handler methods
register_command_handler
self for fluent chaining.
The
Command subclass this handler processes (e.g., CreateOrderCommand).Either a handler instance (eager) or a zero-argument callable that returns a handler (lazy). Factories are invoked once on first resolution and the result is cached.
Returns
self, enabling fluent chaining: registry.register_command_handler(...).register_command_handler(...).DuplicateHandlerError — if command_type is already registered and allow_override=False.
resolve_command_handler
command_type. If the registered entry is a factory (callable that is not an ICommandHandler), it is invoked and the resulting instance is cached, replacing the factory in the registry.
The command class whose handler should be resolved.
The resolved (and possibly cached) handler instance.
HandlerNotFoundError — if no handler is registered for command_type.
Query handler methods
register_query_handler
self for fluent chaining.
The
Query subclass this handler processes (e.g., GetProductByIdQuery).A handler instance or a zero-argument factory callable.
Returns
self for fluent chaining.DuplicateHandlerError — if query_type is already registered and allow_override=False.
resolve_query_handler
query_type. Factory entries are invoked once and cached.
The query class whose handler should be resolved.
The resolved handler instance.
HandlerNotFoundError — if no handler is registered for query_type.
Properties
registered_commands
An immutable set of all command types currently registered. Useful for introspection, health checks, and debugging.
registered_queries
An immutable set of all query types currently registered.