-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstate.go
49 lines (43 loc) · 847 Bytes
/
state.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
package go_Dag
type State int32
const (
// StatePending 任务初始状态
StatePending State = iota
// StateReceived 收到任务
StateReceived
// StateStarted 开始执行任务
StateStarted
// StateRetry 准备重试
StateRetry
// StateSuccess 任务成功
StateSuccess
// StateFailure 任务失败
StateFailure
)
func (s State) String() string {
switch s {
case StatePending:
return "PENDING"
case StateReceived:
return "RECEIVED"
case StateStarted:
return "STARTED"
case StateRetry:
return "RETRY"
case StateSuccess:
return "SUCCESS"
case StateFailure:
return "FAILURE"
default:
return "UNKNOWN"
}
}
func (s State) IsCompleted() bool {
return s.IsSuccess() || s.IsFailure()
}
func (s State) IsSuccess() bool {
return s == StateSuccess
}
func (s State) IsFailure() bool {
return s == StateFailure
}