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 63
/
execution.go
146 lines (125 loc) · 5.36 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
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
package mocks
import (
"context"
"time"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin"
)
type CreateExecutionFunc func(
ctx context.Context, request admin.ExecutionCreateRequest, requestedAt time.Time) (
*admin.ExecutionCreateResponse, error)
type RelaunchExecutionFunc func(
ctx context.Context, request admin.ExecutionRelaunchRequest, requestedAt time.Time) (
*admin.ExecutionCreateResponse, error)
type RecoverExecutionFunc func(ctx context.Context, request admin.ExecutionRecoverRequest, requestedAt time.Time) (
*admin.ExecutionCreateResponse, error)
type CreateExecutionEventFunc func(ctx context.Context, request admin.WorkflowExecutionEventRequest) (
*admin.WorkflowExecutionEventResponse, error)
type GetExecutionFunc func(ctx context.Context, request admin.WorkflowExecutionGetRequest) (*admin.Execution, error)
type UpdateExecutionFunc func(ctx context.Context, request admin.ExecutionUpdateRequest, requestedAt time.Time) (
*admin.ExecutionUpdateResponse, error)
type GetExecutionDataFunc func(ctx context.Context, request admin.WorkflowExecutionGetDataRequest) (
*admin.WorkflowExecutionGetDataResponse, error)
type ListExecutionFunc func(ctx context.Context, request admin.ResourceListRequest) (*admin.ExecutionList, error)
type TerminateExecutionFunc func(
ctx context.Context, request admin.ExecutionTerminateRequest) (*admin.ExecutionTerminateResponse, error)
type MockExecutionManager struct {
createExecutionFunc CreateExecutionFunc
relaunchExecutionFunc RelaunchExecutionFunc
RecoverExecutionFunc RecoverExecutionFunc
createExecutionEventFunc CreateExecutionEventFunc
getExecutionFunc GetExecutionFunc
updateExecutionFunc UpdateExecutionFunc
getExecutionDataFunc GetExecutionDataFunc
listExecutionFunc ListExecutionFunc
terminateExecutionFunc TerminateExecutionFunc
}
func (m *MockExecutionManager) SetCreateCallback(createFunction CreateExecutionFunc) {
m.createExecutionFunc = createFunction
}
func (m *MockExecutionManager) CreateExecution(
ctx context.Context, request admin.ExecutionCreateRequest, requestedAt time.Time) (
*admin.ExecutionCreateResponse, error) {
if m.createExecutionFunc != nil {
return m.createExecutionFunc(ctx, request, requestedAt)
}
return nil, nil
}
func (m *MockExecutionManager) SetRelaunchCallback(relaunchFunction RelaunchExecutionFunc) {
m.relaunchExecutionFunc = relaunchFunction
}
func (m *MockExecutionManager) RelaunchExecution(
ctx context.Context, request admin.ExecutionRelaunchRequest, requestedAt time.Time) (
*admin.ExecutionCreateResponse, error) {
if m.relaunchExecutionFunc != nil {
return m.relaunchExecutionFunc(ctx, request, requestedAt)
}
return nil, nil
}
func (m *MockExecutionManager) SetCreateEventCallback(createEventFunc CreateExecutionEventFunc) {
m.createExecutionEventFunc = createEventFunc
}
func (m *MockExecutionManager) RecoverExecution(ctx context.Context, request admin.ExecutionRecoverRequest, requestedAt time.Time) (
*admin.ExecutionCreateResponse, error) {
if m.RecoverExecutionFunc != nil {
return m.RecoverExecutionFunc(ctx, request, requestedAt)
}
return &admin.ExecutionCreateResponse{}, nil
}
func (m *MockExecutionManager) CreateWorkflowEvent(
ctx context.Context,
request admin.WorkflowExecutionEventRequest) (*admin.WorkflowExecutionEventResponse, error) {
if m.createExecutionEventFunc != nil {
return m.createExecutionEventFunc(ctx, request)
}
return nil, nil
}
func (m *MockExecutionManager) SetUpdateExecutionCallback(updateExecutionFunc UpdateExecutionFunc) {
m.updateExecutionFunc = updateExecutionFunc
}
func (m *MockExecutionManager) UpdateExecution(ctx context.Context, request admin.ExecutionUpdateRequest,
requestedAt time.Time) (*admin.ExecutionUpdateResponse, error) {
if m.updateExecutionFunc != nil {
return m.updateExecutionFunc(ctx, request, requestedAt)
}
return nil, nil
}
func (m *MockExecutionManager) SetGetCallback(getExecutionFunc GetExecutionFunc) {
m.getExecutionFunc = getExecutionFunc
}
func (m *MockExecutionManager) GetExecution(
ctx context.Context, request admin.WorkflowExecutionGetRequest) (*admin.Execution, error) {
if m.getExecutionFunc != nil {
return m.getExecutionFunc(ctx, request)
}
return nil, nil
}
func (m *MockExecutionManager) SetGetDataCallback(getExecutionDataFunc GetExecutionDataFunc) {
m.getExecutionDataFunc = getExecutionDataFunc
}
func (m *MockExecutionManager) GetExecutionData(ctx context.Context, request admin.WorkflowExecutionGetDataRequest) (
*admin.WorkflowExecutionGetDataResponse, error) {
if m.getExecutionDataFunc != nil {
return m.getExecutionDataFunc(ctx, request)
}
return nil, nil
}
func (m *MockExecutionManager) SetListCallback(listExecutionFunc ListExecutionFunc) {
m.listExecutionFunc = listExecutionFunc
}
func (m *MockExecutionManager) ListExecutions(
ctx context.Context, request admin.ResourceListRequest) (*admin.ExecutionList, error) {
if m.listExecutionFunc != nil {
return m.listExecutionFunc(ctx, request)
}
return nil, nil
}
func (m *MockExecutionManager) SetTerminateExecutionCallback(terminateExecutionFunc TerminateExecutionFunc) {
m.terminateExecutionFunc = terminateExecutionFunc
}
func (m *MockExecutionManager) TerminateExecution(
ctx context.Context, request admin.ExecutionTerminateRequest) (*admin.ExecutionTerminateResponse, error) {
if m.terminateExecutionFunc != nil {
return m.terminateExecutionFunc(ctx, request)
}
return nil, nil
}