-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathexecution.go
81 lines (74 loc) · 2.18 KB
/
execution.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
package gobatch
import (
"github.com/chararch/gobatch/status"
"time"
)
//JobExecution represents context of a job execution
type JobExecution struct {
JobExecutionId int64
JobInstanceId int64
JobName string
JobParams map[string]interface{}
JobStatus status.BatchStatus
StepExecutions []*StepExecution
JobContext *BatchContext
CreateTime time.Time
StartTime time.Time
EndTime time.Time
FailError BatchError
Version int64
}
//AddStepExecution add a step execution in this job
func (e *JobExecution) AddStepExecution(execution *StepExecution) {
e.StepExecutions = append(e.StepExecutions, execution)
}
//StepExecution represents context of a step execution
type StepExecution struct {
StepExecutionId int64
StepName string
StepStatus status.BatchStatus
StepContext *BatchContext
StepContextId int64
StepExecutionContext *BatchContext
JobExecution *JobExecution
CreateTime time.Time
StartTime time.Time
EndTime time.Time
ReadCount int64
WriteCount int64
CommitCount int64
FilterCount int64
ReadSkipCount int64
WriteSkipCount int64
ProcessSkipCount int64
RollbackCount int64
FailError BatchError
LastUpdated time.Time
Version int64
}
func (execution *StepExecution) finish(err BatchError) {
if err != nil {
execution.StepStatus = status.FAILED
execution.FailError = err
execution.EndTime = time.Now()
} else {
execution.StepStatus = status.COMPLETED
execution.EndTime = time.Now()
}
}
func (execution *StepExecution) start() {
execution.StartTime = time.Now()
execution.StepStatus = status.STARTED
}
func (execution *StepExecution) deepCopy() *StepExecution {
result := &StepExecution{
StepName: execution.StepName,
StepStatus: status.STARTING,
StepContext: execution.StepContext.DeepCopy(),
StepContextId: execution.StepContextId,
StepExecutionContext: execution.StepExecutionContext.DeepCopy(),
JobExecution: execution.JobExecution,
CreateTime: time.Now(),
}
return result
}