// Package event define real time data evnet operation functions package event import ( "modelRT/constants" ) // NewTaskSubmittedMessage creates a message record for when a task is submitted to the queue func NewTaskSubmittedMessage(taskID, taskType string, priority int) (*EventRecord, error) { return NewPlatformEventRecord( int(constants.EventGeneralPlatformSoft), 0, "async_task_submitted", WithCategory(constants.MessageTaskSubmittedCategory), WithCondition(map[string]any{ "task_id": taskID, "task_type": taskType, "priority": priority, }), ) } // NewTaskRunningMessage creates a message record for when a task begins execution func NewTaskRunningMessage(taskID, taskType string) (*EventRecord, error) { return NewPlatformEventRecord( int(constants.EventGeneralPlatformSoft), 0, "async_task_running", WithCategory(constants.MessageTaskRunningCategory), WithCondition(map[string]any{ "task_id": taskID, "task_type": taskType, }), ) } // NewTaskCompletedMessage creates a message record for when a task finishes successfully func NewTaskCompletedMessage(taskID, taskType string, executionMs int64) (*EventRecord, error) { return NewPlatformEventRecord( int(constants.EventGeneralPlatformSoft), 0, "async_task_completed", WithCategory(constants.MessageTaskCompletedCategory), WithCondition(map[string]any{ "task_id": taskID, "task_type": taskType, }), WithResult(map[string]any{ "execution_ms": executionMs, }), ) } // NewTaskFailedMessage creates a message record for when a task fails during execution func NewTaskFailedMessage(taskID, taskType, reason string) (*EventRecord, error) { return NewPlatformEventRecord( int(constants.EventGeneralPlatformSoft), 0, "async_task_failed", WithCategory(constants.MessageTaskFailedCategory), WithCondition(map[string]any{ "task_id": taskID, "task_type": taskType, "reason": reason, }), ) } // NewTaskCancelledMessage creates a message record for when a task is cancelled by a user func NewTaskCancelledMessage(taskID, taskType string) (*EventRecord, error) { return NewPlatformEventRecord( int(constants.EventGeneralPlatformSoft), 0, "async_task_cancelled", WithCategory(constants.MessageTaskCancelledCategory), WithCondition(map[string]any{ "task_id": taskID, "task_type": taskType, }), ) }