This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
/
transition_info.go
175 lines (139 loc) · 4.18 KB
/
transition_info.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
package handler
import (
"time"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/event"
"github.com/flyteorg/flytestdlib/storage"
)
//go:generate enumer --type=EPhase --trimprefix=EPhase
type EPhase uint8
const (
EPhaseUndefined EPhase = iota
EPhaseNotReady
EPhaseQueued
EPhaseRunning
EPhaseSkip
EPhaseFailed
EPhaseRetryableFailure
EPhaseSuccess
EPhaseTimedout
EPhaseFailing
EPhaseDynamicRunning
EPhaseRecovered
)
func (p EPhase) IsTerminal() bool {
if p == EPhaseFailed || p == EPhaseSuccess || p == EPhaseSkip || p == EPhaseTimedout || p == EPhaseRecovered {
return true
}
return false
}
type DynamicNodeInfo struct {
}
type WorkflowNodeInfo struct {
LaunchedWorkflowID *core.WorkflowExecutionIdentifier
}
type BranchNodeInfo struct {
}
// Carries any information that should be sent as part of NodeEvents
type TaskNodeInfo struct {
TaskNodeMetadata *event.TaskNodeMetadata
}
type OutputInfo struct {
OutputURI storage.DataReference
}
type ExecutionInfo struct {
DynamicNodeInfo *DynamicNodeInfo
WorkflowNodeInfo *WorkflowNodeInfo
BranchNodeInfo *BranchNodeInfo
OutputInfo *OutputInfo
TaskNodeInfo *TaskNodeInfo
}
type PhaseInfo struct {
p EPhase
occurredAt time.Time
err *core.ExecutionError
info *ExecutionInfo
reason string
}
func (p PhaseInfo) GetPhase() EPhase {
return p.p
}
func (p PhaseInfo) GetOccurredAt() time.Time {
return p.occurredAt
}
func (p PhaseInfo) GetErr() *core.ExecutionError {
return p.err
}
func (p PhaseInfo) GetInfo() *ExecutionInfo {
return p.info
}
func (p PhaseInfo) GetReason() string {
return p.reason
}
func (p PhaseInfo) WithInfo(i *ExecutionInfo) PhaseInfo {
return PhaseInfo{
p: p.p,
occurredAt: p.occurredAt,
err: p.err,
info: i,
reason: p.reason,
}
}
var PhaseInfoUndefined = PhaseInfo{p: EPhaseUndefined}
func phaseInfo(p EPhase, err *core.ExecutionError, info *ExecutionInfo, reason string) PhaseInfo {
return PhaseInfo{
p: p,
err: err,
occurredAt: time.Now(),
info: info,
reason: reason,
}
}
func PhaseInfoNotReady(reason string) PhaseInfo {
return phaseInfo(EPhaseNotReady, nil, nil, reason)
}
func PhaseInfoQueued(reason string) PhaseInfo {
return phaseInfo(EPhaseQueued, nil, nil, reason)
}
func PhaseInfoRunning(info *ExecutionInfo) PhaseInfo {
return phaseInfo(EPhaseRunning, nil, info, "running")
}
func PhaseInfoDynamicRunning(info *ExecutionInfo) PhaseInfo {
return phaseInfo(EPhaseDynamicRunning, nil, info, "dynamic workflow running")
}
func PhaseInfoSuccess(info *ExecutionInfo) PhaseInfo {
return phaseInfo(EPhaseSuccess, nil, info, "successfully completed")
}
func PhaseInfoSkip(info *ExecutionInfo, reason string) PhaseInfo {
return phaseInfo(EPhaseSkip, nil, info, reason)
}
func PhaseInfoTimedOut(info *ExecutionInfo, reason string) PhaseInfo {
return phaseInfo(EPhaseTimedout, nil, info, reason)
}
func PhaseInfoRecovered(info *ExecutionInfo) PhaseInfo {
return phaseInfo(EPhaseRecovered, nil, info, "successfully recovered")
}
func phaseInfoFailed(p EPhase, err *core.ExecutionError, info *ExecutionInfo) PhaseInfo {
if err == nil {
err = &core.ExecutionError{
Code: "Unknown",
Message: "Unknown error message",
}
}
return phaseInfo(p, err, info, err.Message)
}
func PhaseInfoFailure(kind core.ExecutionError_ErrorKind, code, reason string, info *ExecutionInfo) PhaseInfo {
return phaseInfoFailed(EPhaseFailed, &core.ExecutionError{Kind: kind, Code: code, Message: reason}, info)
}
func PhaseInfoFailureErr(err *core.ExecutionError, info *ExecutionInfo) PhaseInfo {
return phaseInfoFailed(EPhaseFailed, err, info)
}
func PhaseInfoFailingErr(err *core.ExecutionError, info *ExecutionInfo) PhaseInfo {
return phaseInfoFailed(EPhaseFailing, err, info)
}
func PhaseInfoRetryableFailure(kind core.ExecutionError_ErrorKind, code, reason string, info *ExecutionInfo) PhaseInfo {
return phaseInfoFailed(EPhaseRetryableFailure, &core.ExecutionError{Kind: kind, Code: code, Message: reason}, info)
}
func PhaseInfoRetryableFailureErr(err *core.ExecutionError, info *ExecutionInfo) PhaseInfo {
return phaseInfoFailed(EPhaseRetryableFailure, err, info)
}