-
Notifications
You must be signed in to change notification settings - Fork 774
/
visibility_store.go
142 lines (126 loc) · 6.71 KB
/
visibility_store.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
// The MIT License
//
// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved.
//
// Copyright (c) 2020 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.
package store
// -aux_files is required here due to Closeable interface being in another file.
//go:generate mockgen -copyright_file ../../../../LICENSE -package $GOPACKAGE -source $GOFILE -destination visibility_store_mock.go -aux_files go.temporal.io/server/common/persistence=../../data_interfaces.go
import (
"context"
"time"
commonpb "go.temporal.io/api/common/v1"
enumspb "go.temporal.io/api/enums/v1"
"go.temporal.io/server/common/persistence"
"go.temporal.io/server/common/persistence/visibility/manager"
)
type (
// VisibilityStore is the store interface for visibility
VisibilityStore interface {
persistence.Closeable
GetName() string
GetIndexName() string
// Validate search attributes based on the store constraints. It returns a new map containing
// only search attributes with valid values. If there are invalid values, an error of type
// VisibilityStoreInvalidValuesError wraps all invalid values errors.
ValidateCustomSearchAttributes(searchAttributes map[string]any) (map[string]any, error)
// Write APIs.
RecordWorkflowExecutionStarted(ctx context.Context, request *InternalRecordWorkflowExecutionStartedRequest) error
RecordWorkflowExecutionClosed(ctx context.Context, request *InternalRecordWorkflowExecutionClosedRequest) error
UpsertWorkflowExecution(ctx context.Context, request *InternalUpsertWorkflowExecutionRequest) error
DeleteWorkflowExecution(ctx context.Context, request *manager.VisibilityDeleteWorkflowExecutionRequest) error
// Read APIs.
ListOpenWorkflowExecutions(ctx context.Context, request *manager.ListWorkflowExecutionsRequest) (*InternalListWorkflowExecutionsResponse, error)
ListClosedWorkflowExecutions(ctx context.Context, request *manager.ListWorkflowExecutionsRequest) (*InternalListWorkflowExecutionsResponse, error)
ListOpenWorkflowExecutionsByType(ctx context.Context, request *manager.ListWorkflowExecutionsByTypeRequest) (*InternalListWorkflowExecutionsResponse, error)
ListClosedWorkflowExecutionsByType(ctx context.Context, request *manager.ListWorkflowExecutionsByTypeRequest) (*InternalListWorkflowExecutionsResponse, error)
ListOpenWorkflowExecutionsByWorkflowID(ctx context.Context, request *manager.ListWorkflowExecutionsByWorkflowIDRequest) (*InternalListWorkflowExecutionsResponse, error)
ListClosedWorkflowExecutionsByWorkflowID(ctx context.Context, request *manager.ListWorkflowExecutionsByWorkflowIDRequest) (*InternalListWorkflowExecutionsResponse, error)
ListClosedWorkflowExecutionsByStatus(ctx context.Context, request *manager.ListClosedWorkflowExecutionsByStatusRequest) (*InternalListWorkflowExecutionsResponse, error)
ListWorkflowExecutions(ctx context.Context, request *manager.ListWorkflowExecutionsRequestV2) (*InternalListWorkflowExecutionsResponse, error)
ScanWorkflowExecutions(ctx context.Context, request *manager.ListWorkflowExecutionsRequestV2) (*InternalListWorkflowExecutionsResponse, error)
CountWorkflowExecutions(ctx context.Context, request *manager.CountWorkflowExecutionsRequest) (*manager.CountWorkflowExecutionsResponse, error)
GetWorkflowExecution(ctx context.Context, request *manager.GetWorkflowExecutionRequest) (*InternalGetWorkflowExecutionResponse, error)
}
// InternalWorkflowExecutionInfo is visibility info for internal response
InternalWorkflowExecutionInfo struct {
WorkflowID string
RunID string
TypeName string
StartTime time.Time
ExecutionTime time.Time
CloseTime time.Time
Status enumspb.WorkflowExecutionStatus
HistoryLength int64
HistorySizeBytes int64
StateTransitionCount int64
Memo *commonpb.DataBlob
TaskQueue string
SearchAttributes *commonpb.SearchAttributes
ParentWorkflowID string
ParentRunID string
}
// InternalListWorkflowExecutionsResponse is response from ListWorkflowExecutions
InternalListWorkflowExecutionsResponse struct {
Executions []*InternalWorkflowExecutionInfo
// 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
}
// InternalGetWorkflowExecutionResponse is response from GetWorkflowExecution
InternalGetWorkflowExecutionResponse struct {
Execution *InternalWorkflowExecutionInfo
}
// InternalVisibilityRequestBase is a base request to visibility APIs.
InternalVisibilityRequestBase struct {
NamespaceID string
WorkflowID string
RunID string
WorkflowTypeName string
StartTime time.Time
Status enumspb.WorkflowExecutionStatus
ExecutionTime time.Time
TaskID int64
ShardID int32
Memo *commonpb.DataBlob
TaskQueue string
SearchAttributes *commonpb.SearchAttributes
ParentWorkflowID *string
ParentRunID *string
}
// InternalRecordWorkflowExecutionStartedRequest request to RecordWorkflowExecutionStarted
InternalRecordWorkflowExecutionStartedRequest struct {
*InternalVisibilityRequestBase
}
// InternalRecordWorkflowExecutionClosedRequest is request to RecordWorkflowExecutionClosed
InternalRecordWorkflowExecutionClosedRequest struct {
*InternalVisibilityRequestBase
CloseTime time.Time
HistoryLength int64
HistorySizeBytes int64
ExecutionDuration time.Duration
StateTransitionCount int64
}
// InternalUpsertWorkflowExecutionRequest is request to UpsertWorkflowExecution
InternalUpsertWorkflowExecutionRequest struct {
*InternalVisibilityRequestBase
}
)