-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.go
More file actions
116 lines (93 loc) · 3.33 KB
/
models.go
File metadata and controls
116 lines (93 loc) · 3.33 KB
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
package gorkflow
import (
"encoding/json"
"time"
)
// RunStatus represents the current state of a workflow execution
type RunStatus string
const (
RunStatusPending RunStatus = "PENDING"
RunStatusRunning RunStatus = "RUNNING"
RunStatusCompleted RunStatus = "COMPLETED"
RunStatusFailed RunStatus = "FAILED"
RunStatusCancelled RunStatus = "CANCELLED"
)
// IsTerminal returns true if the status is a final state
func (s RunStatus) IsTerminal() bool {
return s == RunStatusCompleted || s == RunStatusFailed || s == RunStatusCancelled
}
// String returns the string representation
func (s RunStatus) String() string {
return string(s)
}
// StepStatus represents the current state of a step execution
type StepStatus string
const (
StepStatusPending StepStatus = "PENDING"
StepStatusRunning StepStatus = "RUNNING"
StepStatusCompleted StepStatus = "COMPLETED"
StepStatusFailed StepStatus = "FAILED"
StepStatusSkipped StepStatus = "SKIPPED"
StepStatusRetrying StepStatus = "RETRYING"
)
// IsTerminal returns true if the status is a final state
func (s StepStatus) IsTerminal() bool {
return s == StepStatusCompleted || s == StepStatusFailed || s == StepStatusSkipped
}
// String returns the string representation
func (s StepStatus) String() string {
return string(s)
}
// WorkflowRun represents a single workflow execution instance
type WorkflowRun struct {
// Identity
RunID string `json:"runId"`
WorkflowID string `json:"workflowId"`
WorkflowVersion string `json:"workflowVersion"`
// Status
Status RunStatus `json:"status"`
Progress float64 `json:"progress"` // 0.0 to 1.0
// Timing
CreatedAt time.Time `json:"createdAt"`
StartedAt *time.Time `json:"startedAt,omitempty"`
CompletedAt *time.Time `json:"completedAt,omitempty"`
UpdatedAt time.Time `json:"updatedAt"`
// Input/Output (serialized as JSON bytes)
Input json.RawMessage `json:"input,omitempty"`
Output json.RawMessage `json:"output,omitempty"`
// Error handling
Error *WorkflowError `json:"error,omitempty"`
// Metadata
ResourceID string `json:"resourceId,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
// Custom context (serialized as JSON bytes)
Context json.RawMessage `json:"context,omitempty"`
}
// StepExecution tracks individual step execution within a workflow run
type StepExecution struct {
// Identity
RunID string `json:"runId"`
StepID string `json:"stepId"`
ExecutionIndex int `json:"executionIndex"` // For tracking across retries
// Status
Status StepStatus `json:"status"`
// Timing
StartedAt *time.Time `json:"startedAt,omitempty"`
CompletedAt *time.Time `json:"completedAt,omitempty"`
DurationMs int64 `json:"durationMs"`
// Input/Output (serialized as JSON bytes)
Input json.RawMessage `json:"input,omitempty"`
Output json.RawMessage `json:"output,omitempty"`
// Error handling
Error *StepError `json:"error,omitempty"`
Attempt int `json:"attempt"` // Current retry attempt
// Metadata
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
// WorkflowState holds business data separate from execution metadata
type WorkflowState struct {
RunID string `json:"runId"`
Data map[string][]byte `json:"data"` // Key-value store (values are JSON)
UpdatedAt time.Time `json:"updatedAt"`
}