activation¶
Message handler activation module.
This module provides classes for registering and activating message handlers based on message types. The handler activator pattern is core to how Mersal dispatches messages to the appropriate handlers.
- class mersal.activation.BuiltinHandlerActivator[source]¶
Bases:
objectDefault implementation of the handler activator pattern.
This class manages the registration and activation of message handlers based on message types. It stores handler factories indexed by message type and instantiates the appropriate handlers when a message needs to be processed.
- property app: Mersal¶
Get the associated application instance.
- Returns:
The Mersal application instance
- async get_handlers(message: MessageT, transaction_context: TransactionContext) Sequence[MessageHandler[MessageT]][source]¶
Get handlers for the specified message.
- register(message_type: type[MessageT], factory: HandlerFactory[MessageT]) BuiltinHandlerActivator[source]¶
Register a handler factory for a specific message type.
- class mersal.activation.HandlerActivator[source]¶
Bases:
ProtocolProtocol defining the interface for activating message handlers.
The HandlerActivator is responsible for registering message handlers and returning the appropriate handlers for a given message type during message processing.
- __init__(*args, **kwargs)¶
- async get_handlers(message: MessageT, transaction_context: TransactionContext) Sequence[MessageHandler[MessageT]][source]¶
Retrieve handlers for the given message.
- register(message_type: type[MessageT], factory: HandlerFactory[MessageT]) HandlerActivator[source]¶
Register a handler factory for a specific message type.