Add domain states and event runtime (T-002)
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package application
|
||||
|
||||
// EventType identifies an application event consumed by UI adapters.
|
||||
type EventType string
|
||||
|
||||
const (
|
||||
EventCatalogRefreshed EventType = "CatalogRefreshed"
|
||||
EventCatalogRejected EventType = "CatalogRejected"
|
||||
EventDownloadStarted EventType = "DownloadStarted"
|
||||
EventDownloadProgress EventType = "DownloadProgress"
|
||||
EventDownloadPaused EventType = "DownloadPaused"
|
||||
EventDownloadCompleted EventType = "DownloadCompleted"
|
||||
EventDownloadFailed EventType = "DownloadFailed"
|
||||
EventInstallCompleted EventType = "InstallCompleted"
|
||||
EventInstallRolledBack EventType = "InstallRolledBack"
|
||||
EventAppStarted EventType = "AppStarted"
|
||||
EventAppExited EventType = "AppExited"
|
||||
EventLicenseChanged EventType = "LicenseChanged"
|
||||
)
|
||||
|
||||
var validEventTypes = map[EventType]struct{}{
|
||||
EventCatalogRefreshed: {},
|
||||
EventCatalogRejected: {},
|
||||
EventDownloadStarted: {},
|
||||
EventDownloadProgress: {},
|
||||
EventDownloadPaused: {},
|
||||
EventDownloadCompleted: {},
|
||||
EventDownloadFailed: {},
|
||||
EventInstallCompleted: {},
|
||||
EventInstallRolledBack: {},
|
||||
EventAppStarted: {},
|
||||
EventAppExited: {},
|
||||
EventLicenseChanged: {},
|
||||
}
|
||||
|
||||
// Valid reports whether eventType is part of the documented event contract.
|
||||
func (eventType EventType) Valid() bool {
|
||||
_, ok := validEventTypes[eventType]
|
||||
return ok
|
||||
}
|
||||
|
||||
// Event is the common envelope delivered from background use cases to adapters.
|
||||
//
|
||||
// Payload is event-specific and will be replaced by concrete payload types as
|
||||
// the corresponding use cases are implemented.
|
||||
type Event struct {
|
||||
Type EventType
|
||||
RequestID string
|
||||
AppID string
|
||||
Payload any
|
||||
}
|
||||
Reference in New Issue
Block a user