application.cqrs.computed_views¶
src.application.cqrs.computed_views
¶
CQRS Registry Computed Views and Helper Functions.
Utility functions for introspecting the CQRS registry. Used by container auto-wiring, tests, and documentation generation.
Reference
- docs/architecture/registry.md
- docs/architecture/cqrs-registry.md
Classes¶
Functions¶
get_all_commands
¶
Get all registered command classes.
Returns:
| Type | Description |
|---|---|
list[type]
|
List of command classes in registry. |
Example
commands = get_all_commands() len(commands) 23 RegisterUser in commands True
Source code in src/application/cqrs/computed_views.py
get_all_queries
¶
Get all registered query classes.
Returns:
| Type | Description |
|---|---|
list[type]
|
List of query classes in registry. |
Example
queries = get_all_queries() len(queries) 18 GetAccount in queries True
Source code in src/application/cqrs/computed_views.py
get_commands_by_category
¶
Get command metadata filtered by category.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
CQRSCategory
|
CQRSCategory to filter by. |
required |
Returns:
| Type | Description |
|---|---|
list[CommandMetadata]
|
List of CommandMetadata entries for that category. |
Example
from src.application.cqrs.metadata import CQRSCategory auth_commands = get_commands_by_category(CQRSCategory.AUTH) len(auth_commands) 7
Source code in src/application/cqrs/computed_views.py
get_queries_by_category
¶
Get query metadata filtered by category.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
CQRSCategory
|
CQRSCategory to filter by. |
required |
Returns:
| Type | Description |
|---|---|
list[QueryMetadata]
|
List of QueryMetadata entries for that category. |
Example
from src.application.cqrs.metadata import CQRSCategory data_queries = get_queries_by_category(CQRSCategory.DATA_SYNC) len(data_queries) 14
Source code in src/application/cqrs/computed_views.py
get_command_metadata
¶
Get metadata for a specific command class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command_class
|
type
|
The command class to look up. |
required |
Returns:
| Type | Description |
|---|---|
CommandMetadata | None
|
CommandMetadata if found, None otherwise. |
Example
from src.application.commands.auth_commands import RegisterUser meta = get_command_metadata(RegisterUser) meta.handler_class.name 'RegisterUserHandler'
Source code in src/application/cqrs/computed_views.py
get_query_metadata
¶
Get metadata for a specific query class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query_class
|
type
|
The query class to look up. |
required |
Returns:
| Type | Description |
|---|---|
QueryMetadata | None
|
QueryMetadata if found, None otherwise. |
Example
from src.application.queries.account_queries import GetAccount meta = get_query_metadata(GetAccount) meta.handler_class.name 'GetAccountHandler'
Source code in src/application/cqrs/computed_views.py
get_commands_with_result_dto
¶
Get all commands that return result DTOs.
Returns:
| Type | Description |
|---|---|
list[CommandMetadata]
|
List of CommandMetadata where has_result_dto is True. |
Example
commands = get_commands_with_result_dto() len(commands) # AuthenticateUser, GenerateAuthTokens, etc. 8
Source code in src/application/cqrs/computed_views.py
get_commands_emitting_events
¶
Get all commands that emit domain events.
Returns:
| Type | Description |
|---|---|
list[CommandMetadata]
|
List of CommandMetadata where emits_events is True. |
Example
commands = get_commands_emitting_events() len(commands) > 15 True
Source code in src/application/cqrs/computed_views.py
get_paginated_queries
¶
Get all queries that support pagination.
Returns:
| Type | Description |
|---|---|
list[QueryMetadata]
|
List of QueryMetadata where is_paginated is True. |
Example
queries = get_paginated_queries() any(q.query_class.name == 'ListTransactionsByAccount' for q in queries) True
Source code in src/application/cqrs/computed_views.py
get_queries_by_cache_policy
¶
Get queries filtered by cache policy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cache_policy
|
CachePolicy
|
CachePolicy to filter by. |
required |
Returns:
| Type | Description |
|---|---|
list[QueryMetadata]
|
List of QueryMetadata with that cache policy. |
Example
from src.application.cqrs.metadata import CachePolicy medium_cache = get_queries_by_cache_policy(CachePolicy.MEDIUM) len(medium_cache) > 0 True
Source code in src/application/cqrs/computed_views.py
get_statistics
¶
Get registry statistics for documentation and monitoring.
Returns:
| Type | Description |
|---|---|
dict[str, int | dict[str, int]]
|
Dict with counts by category, type, etc. |
Example
stats = get_statistics() stats['total_commands'] 23 stats['total_queries'] 18
Source code in src/application/cqrs/computed_views.py
get_handler_class_for_command
¶
Get the handler class for a command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command_class
|
type
|
The command class. |
required |
Returns:
| Type | Description |
|---|---|
type | None
|
Handler class if found, None otherwise. |
Example
from src.application.commands.auth_commands import RegisterUser handler = get_handler_class_for_command(RegisterUser) handler.name 'RegisterUserHandler'
Source code in src/application/cqrs/computed_views.py
get_handler_class_for_query
¶
Get the handler class for a query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query_class
|
type
|
The query class. |
required |
Returns:
| Type | Description |
|---|---|
type | None
|
Handler class if found, None otherwise. |
Example
from src.application.queries.account_queries import GetAccount handler = get_handler_class_for_query(GetAccount) handler.name 'GetAccountHandler'
Source code in src/application/cqrs/computed_views.py
get_all_handler_classes
¶
Get all registered handler classes (commands + queries).
Returns:
| Type | Description |
|---|---|
list[type]
|
List of all handler classes. |
Example
handlers = get_all_handler_classes() len(handlers) # Unique handlers 41
Source code in src/application/cqrs/computed_views.py
validate_registry_consistency
¶
Validate registry for common issues.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of error messages. Empty if registry is consistent. |
Example
errors = validate_registry_consistency() len(errors) 0