python_cqrs_core.command¶
Command interfaces for CQRS pattern.
Extracted from GridFlow backend/src/apps/token_generator/application/common/ports_interfaces/command.py
Attributes¶
Classes¶
Base command interface (write operations). |
|
Command handler interface. |
Module Contents¶
- python_cqrs_core.command.TCommand¶
- python_cqrs_core.command.TResult¶
- class python_cqrs_core.command.ICommand¶
Bases:
abc.ABCBase command interface (write operations).
Commands modify state and may return a result. Use this as a marker interface for all commands.
- Example:
>>> from pydantic import BaseModel >>> >>> class CreateUserCommand(BaseModel, ICommand): ... name: str ... email: str
- class python_cqrs_core.command.ICommandHandler¶
Bases:
abc.ABC,Generic[TCommand,TResult]Command handler interface.
Handles a specific command type and returns a result.
- Example:
>>> class CreateUserHandler(ICommandHandler[CreateUserCommand, User]): ... async def handle(self, command: CreateUserCommand) -> User: ... # Create user logic ... return user
- abstract handle(command: TCommand) TResult¶
- Async:
Handle the command.
- Args:
command: Command to handle
- Returns:
Command result