api.go ×10

Frontier kind: Joint frontier

unlabeled · c_b82129b07939

2 tests · 9881 LOC · 272 files · introduces 1 test · 82 LOC · 4 files

Introduces — evidence that enters the hierarchy at this concept

Code
20 ranges82 lines · 4 files
Tests
1 test

Contains — complete concept membership

All code (extent)
2147 ranges9881 lines · 272 files · Browse complete extent
All tests (intent)
2 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.

1 test introduced at this concept.

Introduced code

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

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

go.temporal.io/server/service/history/api/startworkflow/api.go 55 introduced LOC · 10 ranges

Open complete file

478
479 // handle terminating the current execution (currentWorkflowUpdateAction) and starting a new workflow
480 > var workflowLease api.WorkflowLease api.go
481 > var mutableStateInfo *mutableStateInfo
482 > // Update current execution and create new execution in one transaction.
483 > // We already validated that currentWorkflowConditionFailed.RunID is not empty,
484 > // so the following update won't try to lock the current execution again.
485 > err = api.GetAndUpdateWorkflowWithNew(
486 > ctx,
487 > nil,
488 > workflowKey,
489 > currentExecutionUpdateAction,
490 > func() (historyi.WorkflowContext, historyi.MutableState, error) {
491 > newMutableState, err := api.NewWorkflowWithSignal(
492 > s.shardContext,
493 > s.namespace,
494 > workflowID,
495 > newRunID,
496 > s.request,
497 > nil)
498 > if err != nil {
499 return nil, nil, err
500 }
501
502 > workflowLease, err = s.createOrUpdateLeaseFn(nil, s.shardContext, newMutableState) api.go
503 > if err != nil {
504 return nil, nil, err
505 }
506
507 // extract information from MutableState in case this is an eager start
508 > mutableState := workflowLease.GetMutableState() api.go
509 > mutableStateInfo, err = extractMutableStateInfo(ctx, mutableState)
510 > if err != nil {
511 return nil, nil, err
512 }
513
514 > return workflowLease.GetContext(), mutableState, nil api.go
515 },
516 s.shardContext,
517 s.workflowConsistencyChecker,
518 )
519 > if workflowLease != nil { api.go
520 > workflowLease.GetReleaseFn()(err)
521 > }
522
523 > switch err { api.go
524 > case nil:
525 > if !s.requestEagerStart() {
526 > return &historyservice.StartWorkflowExecutionResponse{
527 > RunId: newRunID,
528 > FirstExecutionRunId: newRunID,
529 > Started: true,
530 > Status: enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
531 > Link: s.generateStartedEventRefLink(newRunID),
532 > }, StartNew, nil
533 > }
534 events, err := s.getWorkflowHistory(ctx, mutableStateInfo)
535 if err != nil {
623 // and recovers the head-of-chain run id (used by the dedup / conflict path for legacy workflows whose
624 // persisted WorkflowExecutionState predates first_execution_run_id).
625 > func extractMutableStateInfo(ctx context.Context, mutableState historyi.MutableState) (*mutableStateInfo, error) { api.go
626 > branchToken, err := mutableState.GetCurrentBranchToken()
627 > if err != nil {
628 return nil, err
629 }
630
631 // Future work for the request retry path: extend the task timeout (by failing / timing out the current task).
632 > workflowTaskSource := mutableState.GetStartedWorkflowTask() api.go
633 > // The workflowTask returned from the mutable state call is generated on the fly and technically doesn't require
634 > // cloning. We clone here just in case that changes.
635 > var workflowTask historyi.WorkflowTaskInfo
636 > if workflowTaskSource != nil {
637 workflowTask = *workflowTaskSource
638 }
639
640 > firstRunID, err := mutableState.GetFirstRunID(ctx) api.go
641 > if err != nil {
642 return nil, err
643 }
644
645 > return &mutableStateInfo{ api.go
646 > branchToken: branchToken,
647 > lastEventID: mutableState.GetNextEventID() - 1,
648 > workflowTask: &workflowTask,
649 > firstExecutionRunID: firstRunID,
650 > }, nil
651 }
652
go.temporal.io/server/service/history/api/update_workflow_util.go 13 introduced LOC · 5 ranges

Open complete file

92 var updateErr error
93 if newWorkflowFn != nil {
94 > newContext, newMutableState, err := newWorkflowFn() update_workflow_util.go
95 > if err != nil {
96 return err
97 }
98 > lastWriteVersion, err := mutableState.GetLastWriteVersion() update_workflow_util.go
99 > if err != nil {
100 return err
101 }
102 > if err = NewWorkflowVersionCheck(shardContext, lastWriteVersion, newMutableState); err != nil { update_workflow_util.go
103 return err
104 }
105
106 > updateErr = workflowLease.GetContext().UpdateWorkflowExecutionWithNewAsActive( update_workflow_util.go
107 > ctx,
108 > shardContext,
109 > newContext,
110 > newMutableState,
111 > )
112 } else {
113 updateErr = workflowLease.GetContext().UpdateWorkflowExecutionAsActive(ctx, shardContext)
119
120 if postActions.AbortUpdates {
121 > workflowLease.GetContext().UpdateRegistry(ctx).Abort(update.AbortReasonWorkflowCompleted) update_workflow_util.go
122 > }
123
124 return nil
go.temporal.io/server/service/history/api/workflow_id_dedup.go 12 introduced LOC · 3 ranges

Open complete file

211 ) (UpdateWorkflowActionFunc, error) {
212 return func(workflowLease WorkflowLease) (*UpdateWorkflowAction, error) {
213 > mutableState := workflowLease.GetMutableState() workflow_id_dedup.go
214 >
215 > if !mutableState.IsWorkflowExecutionRunning() {
216 return nil, consts.ErrWorkflowCompleted
217 }
218
219 // if this termination was requested by a parent that was reset, we need to ensure that the current execution is in fact a child of the given parent.
220 > if parentExecutionInfo != nil && childWorkflowOnly { workflow_id_dedup.go
221 if mutableState.GetExecutionInfo().GetParentWorkflowId() != parentExecutionInfo.Execution.GetWorkflowId() {
222 return nil, &serviceerror.Internal{
225 }
226 }
227 > return UpdateWorkflowTerminate, workflow.TerminateWorkflow( workflow_id_dedup.go
228 > mutableState,
229 > "TerminateIfRunning WorkflowIdReusePolicy",
230 > payloads.EncodeString(fmt.Sprintf("terminated by new runID: %s", newRunID)),
231 > consts.IdentityHistoryService,
232 > false,
233 > nil, // No links necessary.
234 > )
235 }, nil
236 }
go.temporal.io/server/service/history/api/create_workflow_util.go 2 introduced LOC · 2 ranges

Open complete file

199 }
200
201 > if prevLastWriteVersion > newMutableState.GetCurrentVersion() { create_workflow_util.go
202 clusterMetadata := shard.GetClusterMetadata()
203 namespaceEntry := newMutableState.GetNamespaceEntry()