api.go ×14

Frontier kind: Code frontier

unlabeled · c_71ffefcd4a14

13 tests · 5311 LOC · 202 files · introduces 0 tests · 123 LOC · 4 files

Introduces — evidence that enters the hierarchy at this concept

Code
19 ranges123 lines · 4 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
932 ranges5311 lines · 202 files · Browse complete extent
All tests (intent)
13 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

4 files ranked by introduced lines: 123 introduced LOC across 19 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/history/api/getworkflowexecutionhistory/api.go 104 introduced LOC · 14 ranges

Open complete file

125 request *historyservice.GetWorkflowExecutionHistoryRequest,
126 persistenceVisibilityMgr manager.VisibilityManager,
127 > ) (_ *historyservice.GetWorkflowExecutionHistoryResponseWithRaw, retError error) { api.go
128 > namespaceID := namespace.ID(request.GetNamespaceId())
129 > namespaceName := namespace.Name(request.GetRequest().GetNamespace())
130 > err := api.ValidateNamespaceUUID(namespaceID)
131 > if err != nil {
132 return nil, err
133 }
134
135 > isCloseEventOnly := request.Request.GetHistoryEventFilterType() == enumspb.HISTORY_EVENT_FILTER_TYPE_CLOSE_EVENT api.go
136 >
137 > queryMutableState := func(
138 > namespaceUUID namespace.ID,
139 > execution *commonpb.WorkflowExecution,
140 > expectedNextEventID int64,
141 > currentBranchToken []byte,
142 > versionHistoryItem *historyspb.VersionHistoryItem,
143 > versionedTransition *persistencespb.VersionedTransition,
144 > ) (
145 > []byte, // current branch token (to use to retrieve history events)
146 > string, // workflow run ID
147 > int64, // last first event ID (the event ID of the last batch of events in the history)
148 > int64, // last first event transaction id
149 > bool, // whether the workflow is running
150 > *historyspb.VersionHistoryItem, // version history item for the current branch
151 > *persistencespb.VersionedTransition, // last versioned transition
152 > *historyspb.TransientWorkflowTaskInfo, // transient workflow task info
153 > error, // error if any
154 > ) {
155 > response, err := api.GetOrPollWorkflowMutableState(
156 > ctx,
157 > shardContext,
158 > &historyservice.GetMutableStateRequest{
159 > NamespaceId: namespaceUUID.String(),
160 > Execution: execution,
161 > ExpectedNextEventId: expectedNextEventID,
162 > CurrentBranchToken: currentBranchToken,
163 > VersionHistoryItem: versionHistoryItem,
164 > VersionedTransition: versionedTransition,
165 > },
166 > workflowConsistencyChecker,
167 > eventNotifier,
168 > )
169 >
170 > var branchErr *serviceerrors.CurrentBranchChanged
171 > if errors.As(err, &branchErr) && isCloseEventOnly {
172 shardContext.GetLogger().Info("Got CurrentBranchChanged, retry with empty branch token",
173 tag.WorkflowNamespaceID(namespaceUUID.String()),
192 )
193 }
194 > if err != nil { api.go
195 return nil, "", 0, 0, false, nil, nil, nil, err
196 }
197
198 > isWorkflowRunning := response.GetWorkflowStatus() == enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING api.go
199 > currentVersionHistory, err := versionhistory.GetCurrentVersionHistory(response.GetVersionHistories())
200 > if err != nil {
201 return nil, "", 0, 0, false, nil, nil, nil, err
202 }
203 > lastVersionHistoryItem, err := versionhistory.GetLastVersionHistoryItem(currentVersionHistory) api.go
204 > if err != nil {
205 return nil, "", 0, 0, false, nil, nil, nil, err
206 }
207
208 > lastVersionedTransition := transitionhistory.LastVersionedTransition(response.GetTransitionHistory()) api.go
209 > return response.CurrentBranchToken,
210 > response.Execution.GetRunId(),
211 > response.GetLastFirstEventId(),
212 > response.GetNextEventId(),
213 > isWorkflowRunning,
214 > lastVersionHistoryItem,
215 > lastVersionedTransition,
216 > response.GetTransientOrSpeculativeTasks(),
217 > nil
218 }
219
220 > isLongPoll := request.Request.GetWaitNewEvent() api.go
221 > execution := request.Request.Execution
222 > var continuationToken *tokenspb.HistoryContinuation
223 >
224 > var runID string
225 > lastFirstEventID := common.FirstEventID
226 > var nextEventID int64
227 > var isWorkflowRunning bool
228 > var cachedTransientTasks *historyspb.TransientWorkflowTaskInfo
229 >
230 > // process the token for paging
231 > queryNextEventID := common.EndEventID
232 > if request.Request.NextPageToken != nil {
233 continuationToken, err = api.DeserializeHistoryToken(request.Request.NextPageToken)
234 if err != nil {
281 // when data inconsistency occurs. Long term solution should check event
282 // batch pointing backwards within history store.
283 > defer func() { api.go
284 > var dataLossErr *serviceerror.DataLoss
285 > if errors.As(retError, &dataLossErr) {
286 api.TrimHistoryNode(
287 ctx,
296 }()
297
298 > history := &historypb.History{} api.go
299 > history.Events = []*historypb.HistoryEvent{}
300 > var historyBlob []*commonpb.DataBlob
301 > config := shardContext.GetConfig()
302 > sendRawHistoryBetweenInternalServices := config.SendRawHistoryBetweenInternalServices()
303 > sendRawWorkflowHistoryForNamespace := config.SendRawWorkflowHistory(request.Request.GetNamespace())
304 > // fetchGapEvents fetches events in [fromEventID, toEventID) from persistence and appends
305 > // them to the current response (history or historyBlob). Used to close gaps that form
306 > // when events are committed to DB between paginated GetWorkflowExecutionHistory calls.
307 > fetchGapEvents := func(fromEventID, toEventID int64, branchToken []byte) error {
308 if sendRawWorkflowHistoryForNamespace || sendRawHistoryBetweenInternalServices {
309 gapBlob, _, err := api.GetRawHistory(ctx, shardContext, namespaceName, namespaceID, execution,
325 return nil
326 }
327 > if isCloseEventOnly { api.go
328 if !isWorkflowRunning {
329 if sendRawWorkflowHistoryForNamespace || sendRawHistoryBetweenInternalServices {
493 }
494
495 > nextToken, err := api.SerializeHistoryToken(continuationToken) api.go
496 > if err != nil {
497 return nil, err
498 }
499
500 // if SendRawHistoryBetweenInternalServices is enabled, we do this check in frontend service
501 > if len(history.Events) > 0 { api.go
502 err = api.FixFollowEvents(ctx, versionChecker, isCloseEventOnly, history)
503 if err != nil {
506 }
507
508 > var rawHistory [][]byte api.go
509 > // if sendRawHistoryBetweenInternalServices is true and SendRawWorkflowHistory is not enabled for this namespace,
510 > // send history in raw format in History field of historyservice.GetWorkflowExecutionHistoryResponseWithRaw.
511 > // If SendRawWorkflowHistory is enabled for this namespace, raw history will be appended to RawHistory field in
512 > // workflowservice.GetWorkflowExecutionHistoryResponse.
513 > if sendRawHistoryBetweenInternalServices && !sendRawWorkflowHistoryForNamespace {
514 rawHistory = make([][]byte, 0, len(historyBlob))
515 for _, blob := range historyBlob {
518 historyBlob = nil
519 }
520 > return &historyservice.GetWorkflowExecutionHistoryResponseWithRaw{ api.go
521 > Response: &workflowservice.GetWorkflowExecutionHistoryResponse{
522 > History: history,
523 > RawHistory: historyBlob,
524 > NextPageToken: nextToken,
525 > Archived: false,
526 > },
527 >
528 > History: rawHistory,
529 > }, nil
530 }
go.temporal.io/server/api/historyservice/v1/request_response.pb.go 12 introduced LOC · 3 ranges

Open complete file

637 }
638
639 > func (x *GetMutableStateResponse) GetLastFirstEventId() int64 { request_response.pb.go
640 > if x != nil {
641 > return x.LastFirstEventId
642 > }
643 return 0
644 }
749 }
750
751 > func (x *GetMutableStateResponse) GetTransientOrSpeculativeTasks() *v19.TransientWorkflowTaskInfo { request_response.pb.go
752 > if x != nil {
753 > return x.TransientOrSpeculativeTasks
754 > }
755 return nil
756 }
7609 }
7610
7611 > func (x *GetWorkflowExecutionHistoryRequest) GetNamespaceId() string { request_response.pb.go
7612 > if x != nil {
7613 > return x.NamespaceId
7614 > }
7615 return ""
7616 }
go.temporal.io/server/service/history/api/token.go 4 introduced LOC · 1 range

Open complete file

65
66 // NOTE: DO NOT MODIFY UNLESS ALSO APPLIED TO ./service/frontend/token_deprecated.go
67 > func SerializeHistoryToken(token *tokenspb.HistoryContinuation) ([]byte, error) { token.go
68 > if token == nil {
69 > return nil, nil
70 > }
71 return token.Marshal()
72 }
go.temporal.io/server/service/history/history_engine.go 3 introduced LOC · 1 range

Open complete file

1039 ctx context.Context,
1040 request *historyservice.GetWorkflowExecutionHistoryRequest,
1041 > ) (_ *historyservice.GetWorkflowExecutionHistoryResponseWithRaw, retError error) { history_engine.go
1042 > return getworkflowexecutionhistory.Invoke(ctx, e.shardContext, e.workflowConsistencyChecker, e.versionChecker, e.eventNotifier, request, e.persistenceVisibilityMgr)
1043 > }
1044
1045 func (e *historyEngineImpl) GetWorkflowExecutionHistoryReverse(