|
| 1 | +package model |
| 2 | + |
| 3 | +// TaskStartEvent represents the start of a task within a workflow. |
| 4 | +type TaskStartEvent struct { |
| 5 | + WorkflowName string `json:",omitempty"` |
| 6 | + OwnerURL string `json:",omitempty"` |
| 7 | + TaskName string `json:",omitempty"` |
| 8 | + TaskPath []string `json:",omitempty"` |
| 9 | + SessionID string `json:",omitempty"` |
| 10 | + Index int `json:",omitempty"` |
| 11 | + TemplateTag *MetaTag `json:",omitempty"` |
| 12 | +} |
| 13 | + |
| 14 | +// NewTaskStartEvent creates a new TaskStartEvent. |
| 15 | +func NewTaskStartEvent(workflowName, ownerURL, taskName string, taskPath []string, sessionID string, index int, templateTag *MetaTag) *TaskStartEvent { |
| 16 | + return &TaskStartEvent{ |
| 17 | + WorkflowName: workflowName, |
| 18 | + OwnerURL: ownerURL, |
| 19 | + TaskName: taskName, |
| 20 | + TaskPath: taskPath, |
| 21 | + SessionID: sessionID, |
| 22 | + Index: index, |
| 23 | + TemplateTag: templateTag, |
| 24 | + } |
| 25 | +} |
| 26 | + |
| 27 | +// TaskEndEvent represents the end of a task within a workflow. |
| 28 | +type TaskEndEvent struct { |
| 29 | + WorkflowName string `json:",omitempty"` |
| 30 | + OwnerURL string `json:",omitempty"` |
| 31 | + TaskName string `json:",omitempty"` |
| 32 | + TaskPath []string `json:",omitempty"` |
| 33 | + SessionID string `json:",omitempty"` |
| 34 | + Index int `json:",omitempty"` |
| 35 | + Status string `json:",omitempty"` |
| 36 | + Error string `json:",omitempty"` |
| 37 | +} |
| 38 | + |
| 39 | +// NewTaskEndEvent creates a new TaskEndEvent. |
| 40 | +func NewTaskEndEvent(workflowName, ownerURL, taskName string, taskPath []string, sessionID string, index int, status, errMsg string) *TaskEndEvent { |
| 41 | + return &TaskEndEvent{ |
| 42 | + WorkflowName: workflowName, |
| 43 | + OwnerURL: ownerURL, |
| 44 | + TaskName: taskName, |
| 45 | + TaskPath: taskPath, |
| 46 | + SessionID: sessionID, |
| 47 | + Index: index, |
| 48 | + Status: status, |
| 49 | + Error: errMsg, |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +// TaskAsyncStartEvent denotes that a task has launched asynchronous actions. |
| 54 | +type TaskAsyncStartEvent struct { |
| 55 | + TaskPath []string `json:",omitempty"` |
| 56 | + Expected int `json:",omitempty"` |
| 57 | + SessionID string `json:",omitempty"` |
| 58 | +} |
| 59 | + |
| 60 | +// NewTaskAsyncStartEvent creates a new TaskAsyncStartEvent. |
| 61 | +func NewTaskAsyncStartEvent(taskPath []string, expected int, sessionID string) *TaskAsyncStartEvent { |
| 62 | + return &TaskAsyncStartEvent{TaskPath: taskPath, Expected: expected, SessionID: sessionID} |
| 63 | +} |
| 64 | + |
| 65 | +// TaskAsyncDoneEvent denotes completion of asynchronous actions within a task. |
| 66 | +type TaskAsyncDoneEvent struct { |
| 67 | + TaskPath []string `json:",omitempty"` |
| 68 | + Completed int `json:",omitempty"` |
| 69 | + SessionID string `json:",omitempty"` |
| 70 | +} |
| 71 | + |
| 72 | +// NewTaskAsyncDoneEvent creates a new TaskAsyncDoneEvent. |
| 73 | +func NewTaskAsyncDoneEvent(taskPath []string, completed int, sessionID string) *TaskAsyncDoneEvent { |
| 74 | + return &TaskAsyncDoneEvent{TaskPath: taskPath, Completed: completed, SessionID: sessionID} |
| 75 | +} |
0 commit comments