api.go ×11

Frontier kind: Code frontier

unlabeled · c_796e68cca601

6 tests · 9518 LOC · 260 files · introduces 0 tests · 53 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
12 ranges53 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2053 ranges9518 lines · 260 files · Browse complete extent
All tests (intent)
6 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.

2 files ranked by introduced lines: 53 introduced LOC across 12 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/history/api/recordactivitytaskheartbeat/api.go 50 introduced LOC · 11 ranges

Open complete file

20 shard historyi.ShardContext,
21 workflowConsistencyChecker api.WorkflowConsistencyChecker,
22 > ) (resp *historyservice.RecordActivityTaskHeartbeatResponse, retError error) { api.go
23 > request := req.HeartbeatRequest
24 > tokenSerializer := tasktoken.NewSerializer()
25 > token, err0 := tokenSerializer.Deserialize(request.TaskToken)
26 > if err0 != nil {
27 return nil, consts.ErrDeserializingToken
28 }
29
30 > _, err := api.GetActiveNamespace(shard, namespace.ID(req.GetNamespaceId()), token.WorkflowId) api.go
31 > if err != nil {
32 return nil, err
33 }
34 > if err := api.SetActivityTaskRunID(ctx, token, workflowConsistencyChecker); err != nil { api.go
35 return nil, err
36 }
37
38 > var cancelRequested bool api.go
39 > var activityPaused bool
40 > var activityReset bool
41 > err = api.GetAndUpdateWorkflowWithNew(
42 > ctx,
43 > token.Clock,
44 > definition.NewWorkflowKey(
45 > token.NamespaceId,
46 > token.WorkflowId,
47 > token.RunId,
48 > ),
49 > func(workflowLease api.WorkflowLease) (*api.UpdateWorkflowAction, error) {
50 > mutableState := workflowLease.GetMutableState()
51 > if !mutableState.IsWorkflowExecutionRunning() {
52 return nil, consts.ErrWorkflowCompleted
53 }
54
55 > scheduledEventID := token.GetScheduledEventId() api.go
56 > if scheduledEventID == common.EmptyEventID { // client call RecordActivityHeartbeatByID, so get scheduledEventID by activityID
57 scheduledEventID, err0 = api.GetActivityScheduledEventID(token.GetActivityId(), mutableState)
58 if err0 != nil {
60 }
61 }
62 > ai, isRunning := mutableState.GetActivityInfo(scheduledEventID) api.go
63 >
64 > // First check to see if cache needs to be refreshed as we could potentially have stale workflow execution in
65 > // some extreme cassandra failure cases.
66 > if !isRunning && scheduledEventID >= mutableState.GetNextEventID() {
67 metrics.StaleMutableStateCounter.With(shard.GetMetricsHandler()).Record(
68 1,
71 }
72
73 > if !isRunning || api.IsActivityTaskNotFoundForToken(token, ai, nil) { api.go
74 return nil, consts.ErrActivityTaskNotFound
75 }
76
77 // update worker identity if available
78 > if req.HeartbeatRequest.Identity != "" { api.go
79 > ai.RetryLastWorkerIdentity = req.HeartbeatRequest.Identity
80 > }
81
82 > cancelRequested = ai.CancelRequested api.go
83 > activityPaused = ai.Paused
84 > activityReset = ai.ActivityReset
85 >
86 > // Save progress and last HB reported time.
87 > mutableState.UpdateActivityProgress(ai, request)
88 >
89 > return &api.UpdateWorkflowAction{
90 > Noop: false,
91 > CreateWorkflowTask: false,
92 > }, nil
93 },
94 nil,
96 workflowConsistencyChecker,
97 )
98 > if err != nil { api.go
99 return nil, err
100 }
101
102 > return &historyservice.RecordActivityTaskHeartbeatResponse{ api.go
103 > CancelRequested: cancelRequested,
104 > ActivityPaused: activityPaused,
105 > ActivityReset: activityReset,
106 > }, nil
107 }
go.temporal.io/server/service/history/history_engine.go 3 introduced LOC · 1 range

Open complete file

634 ctx context.Context,
635 req *historyservice.RecordActivityTaskHeartbeatRequest,
636 > ) (*historyservice.RecordActivityTaskHeartbeatResponse, error) { history_engine.go
637 > return recordactivitytaskheartbeat.Invoke(ctx, req, e.shardContext, e.workflowConsistencyChecker)
638 > }
639
640 // RequestCancelWorkflowExecution records request cancellation event for workflow execution