54 lines
1.7 KiB
Go
54 lines
1.7 KiB
Go
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"
|
|
EventDownloadCanceled EventType = "DownloadCanceled"
|
|
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: {},
|
|
EventDownloadCanceled: {},
|
|
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
|
|
}
|