-
Notifications
You must be signed in to change notification settings - Fork 787
/
dataVisibilityManagerInterfaces.go
240 lines (214 loc) · 10.8 KB
/
dataVisibilityManagerInterfaces.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//go:generate mockgen -package $GOPACKAGE -destination dataVisibilityManagerInterfaces_mock.go -self_package github.com/uber/cadence/common/persistence github.com/uber/cadence/common/persistence VisibilityManager
// Generate rate limiter wrapper.
//go:generate gowrap gen -g -p . -i VisibilityManager -t ./wrappers/templates/ratelimited.tmpl -o wrappers/ratelimited/visibility_generated.go
// Generate error injection wrapper.
//go:generate gowrap gen -g -p . -i VisibilityManager -t ./wrappers/templates/errorinjector.tmpl -o wrappers/errorinjectors/visibility_generated.go
// Generate metered wrapper.
//go:generate gowrap gen -g -p . -i VisibilityManager -t ./wrappers/templates/metered.tmpl -o wrappers/metered/visibility_generated.go
package persistence
import (
"context"
"github.com/uber/cadence/common/definition"
"github.com/uber/cadence/common/types"
)
// Interfaces for the Visibility Store.
// This is a secondary store that is eventually consistent with the main
// executions store, and stores workflow execution records for visibility
// purposes.
// ErrVisibilityOperationNotSupported is an error which indicates that operation is not supported in selected persistence
var ErrVisibilityOperationNotSupported = &types.BadRequestError{Message: "Operation is not supported. Please use ElasticSearch"}
type (
// RecordWorkflowExecutionStartedRequest is used to add a record of a newly
// started execution
RecordWorkflowExecutionStartedRequest struct {
DomainUUID string
Domain string // not persisted, used as config filter key
Execution types.WorkflowExecution
WorkflowTypeName string
StartTimestamp int64
ExecutionTimestamp int64
WorkflowTimeout int64 // not persisted, used for cassandra ttl
TaskID int64 // not persisted, used as condition update version for ES
Memo *types.Memo
TaskList string
IsCron bool
NumClusters int16
UpdateTimestamp int64 // unit is unix nano, consistent with start/execution timestamp, same in other requests
SearchAttributes map[string][]byte
ShardID int16
}
// RecordWorkflowExecutionClosedRequest is used to add a record of a newly
// closed execution
RecordWorkflowExecutionClosedRequest struct {
DomainUUID string
Domain string // not persisted, used as config filter key
Execution types.WorkflowExecution
WorkflowTypeName string
StartTimestamp int64
ExecutionTimestamp int64
CloseTimestamp int64
Status types.WorkflowExecutionCloseStatus
HistoryLength int64
RetentionSeconds int64
TaskID int64 // not persisted, used as condition update version for ES
Memo *types.Memo
TaskList string
IsCron bool
NumClusters int16
UpdateTimestamp int64
SearchAttributes map[string][]byte
ShardID int16
}
// RecordWorkflowExecutionUninitializedRequest is used to add a record of a newly uninitialized execution
RecordWorkflowExecutionUninitializedRequest struct {
DomainUUID string
Domain string
Execution types.WorkflowExecution
WorkflowTypeName string
UpdateTimestamp int64
ShardID int64
}
// UpsertWorkflowExecutionRequest is used to upsert workflow execution
UpsertWorkflowExecutionRequest struct {
DomainUUID string
Domain string // not persisted, used as config filter key
Execution types.WorkflowExecution
WorkflowTypeName string
StartTimestamp int64
ExecutionTimestamp int64
WorkflowTimeout int64 // not persisted, used for cassandra ttl
TaskID int64 // not persisted, used as condition update version for ES
Memo *types.Memo
TaskList string
IsCron bool
NumClusters int16
UpdateTimestamp int64
SearchAttributes map[string][]byte
ShardID int64
}
// ListWorkflowExecutionsRequest is used to list executions in a domain
ListWorkflowExecutionsRequest struct {
DomainUUID string
Domain string // domain name is not persisted, but used as config filter key
// The earliest end of the time range
EarliestTime int64
// The latest end of the time range
LatestTime int64
// Maximum number of workflow executions per page
PageSize int
// Token to continue reading next page of workflow executions.
// Pass in empty slice for first page.
NextPageToken []byte
}
// ListWorkflowExecutionsByQueryRequest is used to list executions in a domain
ListWorkflowExecutionsByQueryRequest struct {
DomainUUID string
Domain string // domain name is not persisted, but used as config filter key
PageSize int // Maximum number of workflow executions per page
// Token to continue reading next page of workflow executions.
// Pass in empty slice for first page.
NextPageToken []byte
Query string
}
// ListWorkflowExecutionsResponse is the response to ListWorkflowExecutionsRequest
ListWorkflowExecutionsResponse struct {
Executions []*types.WorkflowExecutionInfo
// Token to read next page if there are more workflow executions beyond page size.
// Use this to set NextPageToken on ListWorkflowExecutionsRequest to read the next page.
NextPageToken []byte
}
// CountWorkflowExecutionsRequest is request from CountWorkflowExecutions
CountWorkflowExecutionsRequest struct {
DomainUUID string
Domain string // domain name is not persisted, but used as config filter key
Query string
}
// CountWorkflowExecutionsResponse is response to CountWorkflowExecutions
CountWorkflowExecutionsResponse struct {
Count int64
}
// ListWorkflowExecutionsByTypeRequest is used to list executions of
// a specific type in a domain
ListWorkflowExecutionsByTypeRequest struct {
ListWorkflowExecutionsRequest
WorkflowTypeName string
}
// ListWorkflowExecutionsByWorkflowIDRequest is used to list executions that
// have specific WorkflowID in a domain
ListWorkflowExecutionsByWorkflowIDRequest struct {
ListWorkflowExecutionsRequest
WorkflowID string
}
// ListClosedWorkflowExecutionsByStatusRequest is used to list executions that
// have specific close status
ListClosedWorkflowExecutionsByStatusRequest struct {
ListWorkflowExecutionsRequest
Status types.WorkflowExecutionCloseStatus
}
// GetClosedWorkflowExecutionRequest is used retrieve the record for a specific execution
GetClosedWorkflowExecutionRequest struct {
DomainUUID string
Domain string // domain name is not persisted, but used as config filter key
Execution types.WorkflowExecution
}
// GetClosedWorkflowExecutionResponse is the response to GetClosedWorkflowExecutionRequest
GetClosedWorkflowExecutionResponse struct {
Execution *types.WorkflowExecutionInfo
}
// VisibilityDeleteWorkflowExecutionRequest contains the request params for DeleteWorkflowExecution call
VisibilityDeleteWorkflowExecutionRequest struct {
DomainID string
Domain string
RunID string
WorkflowID string
TaskID int64
}
VisibilityAdminDeletionKey string
// VisibilityManager is used to manage the visibility store
VisibilityManager interface {
Closeable
GetName() string
RecordWorkflowExecutionStarted(ctx context.Context, request *RecordWorkflowExecutionStartedRequest) error
RecordWorkflowExecutionClosed(ctx context.Context, request *RecordWorkflowExecutionClosedRequest) error
RecordWorkflowExecutionUninitialized(ctx context.Context, request *RecordWorkflowExecutionUninitializedRequest) error
UpsertWorkflowExecution(ctx context.Context, request *UpsertWorkflowExecutionRequest) error
ListOpenWorkflowExecutions(ctx context.Context, request *ListWorkflowExecutionsRequest) (*ListWorkflowExecutionsResponse, error)
ListClosedWorkflowExecutions(ctx context.Context, request *ListWorkflowExecutionsRequest) (*ListWorkflowExecutionsResponse, error)
ListOpenWorkflowExecutionsByType(ctx context.Context, request *ListWorkflowExecutionsByTypeRequest) (*ListWorkflowExecutionsResponse, error)
ListClosedWorkflowExecutionsByType(ctx context.Context, request *ListWorkflowExecutionsByTypeRequest) (*ListWorkflowExecutionsResponse, error)
ListOpenWorkflowExecutionsByWorkflowID(ctx context.Context, request *ListWorkflowExecutionsByWorkflowIDRequest) (*ListWorkflowExecutionsResponse, error)
ListClosedWorkflowExecutionsByWorkflowID(ctx context.Context, request *ListWorkflowExecutionsByWorkflowIDRequest) (*ListWorkflowExecutionsResponse, error)
ListClosedWorkflowExecutionsByStatus(ctx context.Context, request *ListClosedWorkflowExecutionsByStatusRequest) (*ListWorkflowExecutionsResponse, error)
DeleteWorkflowExecution(ctx context.Context, request *VisibilityDeleteWorkflowExecutionRequest) error
ListWorkflowExecutions(ctx context.Context, request *ListWorkflowExecutionsByQueryRequest) (*ListWorkflowExecutionsResponse, error)
ScanWorkflowExecutions(ctx context.Context, request *ListWorkflowExecutionsByQueryRequest) (*ListWorkflowExecutionsResponse, error)
CountWorkflowExecutions(ctx context.Context, request *CountWorkflowExecutionsRequest) (*CountWorkflowExecutionsResponse, error)
// NOTE: GetClosedWorkflowExecution is only for persistence testing, currently no index is supported for filtering by RunID
GetClosedWorkflowExecution(ctx context.Context, request *GetClosedWorkflowExecutionRequest) (*GetClosedWorkflowExecutionResponse, error)
DeleteUninitializedWorkflowExecution(ctx context.Context, request *VisibilityDeleteWorkflowExecutionRequest) error
}
)
// IsNopUpsertWorkflowRequest return whether upsert request should be no-op
func IsNopUpsertWorkflowRequest(request *InternalUpsertWorkflowExecutionRequest) bool {
_, exist := request.SearchAttributes[definition.CadenceChangeVersion]
return exist
}