Message Bus#

Important

The synchronous version is generated from the async version

Async#

Propagate commands and events to every registered handles.

exception purgatory.service._async.messagebus.ConfigurationError#

Prevents bad usage of the add_listener.

class purgatory.service._async.messagebus.AsyncMessageRegistry#

Store all the handlers for commands an events.

add_listener(msg_type: Type[purgatory.domain.messages.base.Message], callback: Union[Callable[[Any, purgatory.service._async.unit_of_work.AsyncAbstractUnitOfWork], Coroutine[Any, Any, Any]], Callable[[Any, purgatory.service._async.unit_of_work.AsyncAbstractUnitOfWork], Coroutine[Any, Any, None]]]) None#
remove_listener(msg_type: type, callback: Union[Callable[[Any, purgatory.service._async.unit_of_work.AsyncAbstractUnitOfWork], Coroutine[Any, Any, Any]], Callable[[Any, purgatory.service._async.unit_of_work.AsyncAbstractUnitOfWork], Coroutine[Any, Any, None]]]) None#
async handle(message: purgatory.domain.messages.base.Message, uow: purgatory.service._async.unit_of_work.AsyncAbstractUnitOfWork) Any#

Notify listener of that event registered with messagebus.add_listener. Return the first event from the command.

Sync#

Propagate commands and events to every registered handles.

exception purgatory.service._sync.messagebus.ConfigurationError#

Prevents bad usage of the add_listener.

class purgatory.service._sync.messagebus.SyncMessageRegistry#

Store all the handlers for commands an events.

add_listener(msg_type: Type[purgatory.domain.messages.base.Message], callback: Union[Callable[[Any, purgatory.service._sync.unit_of_work.SyncAbstractUnitOfWork], Any], Callable[[Any, purgatory.service._sync.unit_of_work.SyncAbstractUnitOfWork], None]]) None#
remove_listener(msg_type: type, callback: Union[Callable[[Any, purgatory.service._sync.unit_of_work.SyncAbstractUnitOfWork], Any], Callable[[Any, purgatory.service._sync.unit_of_work.SyncAbstractUnitOfWork], None]]) None#
handle(message: purgatory.domain.messages.base.Message, uow: purgatory.service._sync.unit_of_work.SyncAbstractUnitOfWork) Any#

Notify listener of that event registered with messagebus.add_listener. Return the first event from the command.