Runtime
Overview
The Runtime domain in comby serves as a meta-domain that provides introspection, control, and runtime-specific operations within the application framework. It enables the discovery and management of system capabilities such as permissions, commands, queries, events, aggregates, and event handlers. Additionally, the domain facilitates administrative tasks and monitoring through permissions and server-side events (SSE).
Key Features of the Runtime Domain
The Runtime domain defines several constants that categorize and represent runtime-level functionality:
- Permission Management: Enables viewing and managing permissions at runtime.
- Command and Query Lists: Provides access to all registered commands and queries.
- Event and Event Handler Lists: Allows for listing and inspecting events, event handlers, and their associated functions.
- Aggregate Management: Supports listing and retrieving aggregates dynamically.
- Server-Side Events (SSE): Facilitates real-time monitoring of system events.
- System Information: Exposes system-level information, such as tenant details and administrative group identifiers.
These features make the Runtime domain essential for introspection, debugging, and dynamic control over the system.
Registering Runtime Permissions
The RegisterRuntime function registers a set of predefined runtime permissions in the system. These permissions provide granular control over runtime operations, ensuring that only authorized users or processes can perform sensitive tasks.
Permissions include:
- View Permissions: Access the list of all permissions (RuntimePermissionListType).
- View Commands and Queries: Access the list of all commands (RuntimeCommandList) and queries (RuntimeQueryList).
- View Events and Handlers: Access the list of all events (RuntimeEventList) and event handlers (RuntimeEventHandlerList, RuntimeEventHandlerFuncList).
- Control Event Handlers: Restore the state of event handlers (RuntimeEventHandlerControl).
- Aggregate Management: List all aggregates (RuntimeAggregateList) or retrieve specific ones (RuntimeAggregateRetrieve).
- Real-Time Monitoring: Access the Server-Side Events stream (RuntimeSSE).
- System Information: View system details, such as tenant UUID and administrative group information (RuntimeSystemInfo).
These permissions are registered using the RegisterPermission function, associating each permission with the Runtime domain and a description of its purpose.
Usage of the Runtime Domain
The Runtime domain is primarily used for administrative and operational tasks. It provides insights into the state of the application and allows authorized users to control and monitor various aspects of the system.
For example:
- Debugging and Introspection: Administrators can query the RuntimeCommandList or RuntimeEventList to understand the system's capabilities and inspect registered commands or events.
- Monitoring and Metrics: The RuntimeSSE permission enables access to real-time updates via server-side events, allowing administrators to monitor system activity.
- State Restoration: The RuntimeEventHandlerControl permission allows authorized users to restore the state of event handlers, ensuring consistency after system updates or failures.
- Integration with Other Domains
The Runtime domain complements other domains by exposing their operational metadata. For instance:
- It lists commands, queries, and events registered in various domains, providing a comprehensive overview of system functionality.
- It allows the inspection and management of aggregates, facilitating debugging and administrative tasks.
- It integrates seamlessly with the Permission domain to enforce runtime access control.