Use Case¶
Inbound application port for executing use cases.
Use cases define the application’s orchestration boundary: they coordinate
domain operations to fulfill a specific application intent. Use cases are
pure application-layer logic and must not depend on infrastructure details.
Responsibilities:
- Orchestrate domain interactions.
- Call repositories, outbound ports, and aggregates.
- Maintain transactional consistency (via Unit of Work).
Non-Responsibilities:
- Transport logic (HTTP, messaging systems).
- Persistence implementation details.
- UI or framework-specific concerns.
use_case
¶
Inbound application port for executing use cases.
Use cases define the application’s orchestration boundary: they coordinate
domain operations to fulfill a specific application intent. Use cases are
pure application-layer logic and must not depend on infrastructure details.
Responsibilities
- Orchestrate domain interactions.
- Call repositories, outbound ports, and aggregates.
- Maintain transactional consistency (via Unit of Work).
Non-Responsibilities
- Transport logic (HTTP, messaging systems).
- Persistence implementation details.
- UI or framework-specific concerns.
UseCase
¶
Bases: InboundPort[RequestType, ResponseType], Protocol
Inbound port for defining application use case operations.
A UseCase represents an application-level action that may involve multiple
domain objects and outbound interactions. Use cases must remain free of
infrastructure dependencies and must uphold application-level invariants.
Source code in src/forging_blocks/application/ports/inbound/use_case.py
execute(request: RequestType) -> ResponseType
async
¶
Execute the use case asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
RequestType
|
The request DTO carrying user or system input. |
required |
Returns:
| Type | Description |
|---|---|
ResponseType
|
A DTO or domain object representing the outcome. |
Raises:
| Type | Description |
|---|---|
ApplicationError
|
If the use case fails for domain reasons. |
Notes
This method is asynchronous and should not perform blocking operations.