@@ -2,81 +2,41 @@ package workflow
2
2
3
3
import (
4
4
"github.com/dapr/durabletask-go/api"
5
- "github.com/dapr/durabletask-go/backend "
5
+ "github.com/dapr/durabletask-go/api/protos "
6
6
)
7
7
8
- type Status int
9
-
10
8
const (
11
- StatusRunning Status = iota
12
- StatusCompleted
13
- StatusContinuedAsNew
14
- StatusFailed
15
- StatusCanceled
16
- StatusTerminated
17
- StatusPending
18
- StatusSuspended
19
- StatusUnknown
9
+ StatusRunning = api .RUNTIME_STATUS_RUNNING
10
+ StatusCompleted = api .RUNTIME_STATUS_COMPLETED
11
+ StatusContinuedAsNew = api .RUNTIME_STATUS_CONTINUED_AS_NEW
12
+ StatusFailed = api .RUNTIME_STATUS_FAILED
13
+ StatusCanceled = api .RUNTIME_STATUS_CANCELED
14
+ StatusTerminated = api .RUNTIME_STATUS_TERMINATED
15
+ StatusPending = api .RUNTIME_STATUS_PENDING
16
+ StatusSuspended = api .RUNTIME_STATUS_SUSPENDED
20
17
)
21
18
22
- // String returns the runtime status as a string.
23
- func (s Status ) String () string {
24
- status := [... ]string {
25
- "RUNNING" ,
26
- "COMPLETED" ,
27
- "CONTINUED_AS_NEW" ,
28
- "FAILED" ,
29
- "CANCELED" ,
30
- "TERMINATED" ,
31
- "PENDING" ,
32
- "SUSPENDED" ,
33
- }
34
- if s > StatusSuspended || s < StatusRunning {
35
- return "UNKNOWN"
36
- }
37
- return status [s ]
38
- }
39
-
40
- func (s Status ) RuntimeStatus () api.OrchestrationStatus {
41
- switch s {
42
- case StatusRunning :
43
- return api .RUNTIME_STATUS_RUNNING
44
- case StatusCompleted :
45
- return api .RUNTIME_STATUS_COMPLETED
46
- case StatusContinuedAsNew :
47
- return api .RUNTIME_STATUS_CONTINUED_AS_NEW
48
- case StatusFailed :
49
- return api .RUNTIME_STATUS_FAILED
50
- case StatusCanceled :
51
- return api .RUNTIME_STATUS_CANCELED
52
- case StatusTerminated :
53
- return api .RUNTIME_STATUS_TERMINATED
54
- case StatusPending :
55
- return api .RUNTIME_STATUS_PENDING
56
- case StatusSuspended :
57
- return api .RUNTIME_STATUS_SUSPENDED
58
- }
59
- return - 1
60
- }
61
-
62
- type WorkflowMetadata struct {
63
- metadata * backend.OrchestrationMetadata
64
- }
65
-
66
- // RuntimeStatus returns the status from a workflow state.
67
- func (w * WorkflowMetadata ) RuntimeStatus () Status {
68
- s := Status (w .metadata .GetRuntimeStatus ().Number ())
69
- return s
70
- }
71
-
72
- func (w * WorkflowMetadata ) Metadata () * backend.OrchestrationMetadata {
73
- return w .metadata
74
- }
75
-
76
- func convertStatusSlice (ss []Status ) []api.OrchestrationStatus {
77
- out := []api.OrchestrationStatus {}
78
- for _ , s := range ss {
79
- out = append (out , s .RuntimeStatus ())
19
+ type WorkflowMetadata protos.OrchestrationMetadata
20
+
21
+ func (w WorkflowMetadata ) String () string {
22
+ switch w .RuntimeStatus {
23
+ case api .RUNTIME_STATUS_RUNNING :
24
+ return "RUNNING"
25
+ case api .RUNTIME_STATUS_COMPLETED :
26
+ return "COMPLETED"
27
+ case api .RUNTIME_STATUS_CONTINUED_AS_NEW :
28
+ return "CONTINUED_AS_NEW"
29
+ case api .RUNTIME_STATUS_FAILED :
30
+ return "FAILED"
31
+ case api .RUNTIME_STATUS_CANCELED :
32
+ return "CANCELED"
33
+ case api .RUNTIME_STATUS_TERMINATED :
34
+ return "TERMINATED"
35
+ case api .RUNTIME_STATUS_PENDING :
36
+ return "PENDING"
37
+ case api .RUNTIME_STATUS_SUSPENDED :
38
+ return "SUSPENDED"
39
+ default :
40
+ return ""
80
41
}
81
- return out
82
42
}
0 commit comments