activity.go ×10

Frontier kind: Code frontier

unlabeled · c_f8a07d048000

7 tests · 2430 LOC · 119 files · introduces 0 tests · 28 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
13 ranges28 lines · 3 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
372 ranges2430 lines · 119 files · Browse complete extent
All tests (intent)
7 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.

3 files ranked by introduced lines: 28 introduced LOC across 13 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/chasm/lib/activity/activity.go 21 introduced LOC · 10 ranges

Open complete file

1586 ctx chasm.MutableContext,
1587 input WithToken[*historyservice.RecordActivityTaskHeartbeatRequest],
1588 > ) (*historyservice.RecordActivityTaskHeartbeatResponse, error) { activity.go
1589 > err := a.validateActivityTaskToken(ctx, input.Token, input.Request.GetNamespaceId())
1590 > if err != nil {
1591 return nil, err
1592 }
1593 > prevHeartbeat, _ := a.LastHeartbeat.TryGet(ctx) activity.go
1594 > a.LastHeartbeat = chasm.NewDataField(ctx, &activitypb.ActivityHeartbeatState{
1595 > RecordedTime: timestamppb.New(ctx.Now(a)),
1596 > Details: input.Request.GetHeartbeatRequest().GetDetails(),
1597 > TotalHeartbeatCount: prevHeartbeat.GetTotalHeartbeatCount() + 1,
1598 > })
1599 > if heartbeatTimeout := a.GetHeartbeatTimeout().AsDuration(); heartbeatTimeout > 0 {
1600 ctx.AddTask(
1601 a,
1608 )
1609 }
1610 > response := &historyservice.RecordActivityTaskHeartbeatResponse{} activity.go
1611 > switch a.Status {
1612 case activitypb.ACTIVITY_EXECUTION_STATUS_CANCEL_REQUESTED:
1613 response.CancelRequested = true
1619 // no-op
1620 }
1621 > return response, nil activity.go
1622 }
1623
1903 token *tokenspb.Task,
1904 requestNamespaceID string,
1905 > ) error { activity.go
1906 > if !a.hasAttemptInProgress() {
1907 return serviceerror.NewNotFound("activity task not found")
1908 }
1909 > if token.Attempt != ByIDTokenAttempt && token.Attempt != a.LastAttempt.Get(ctx).GetCount() { activity.go
1910 return serviceerror.NewNotFound("activity task not found")
1911 }
1912 > if token.GetActivityAttemptStamp() != 0 && token.GetActivityAttemptStamp() != a.LastAttempt.Get(ctx).GetStartedStamp() { activity.go
1913 return serviceerror.NewNotFound("activity task not found")
1914 }
1915
1916 > ref, err := chasm.DeserializeComponentRef(token.GetComponentRef()) activity.go
1917 > if err != nil {
1918 return serviceerror.NewInvalidArgument("malformed token")
1919 }
1922 // This prevents cross-namespace token reuse attacks where an attacker could use a valid token from namespace B to
1923 // complete an activity in namespace A.
1924 > if requestNamespaceID != ref.NamespaceID { activity.go
1925 return serviceerror.NewInvalidArgument("token does not match namespace")
1926 }
1927
1928 > return nil activity.go
1929 }
1930
go.temporal.io/server/api/historyservice/v1/request_response.pb.go 4 introduced LOC · 1 range

Open complete file

2407 }
2408
2409 > func (x *RecordActivityTaskHeartbeatRequest) GetHeartbeatRequest() *v1.RecordActivityTaskHeartbeatRequest { request_response.pb.go
2410 > if x != nil {
2411 > return x.HeartbeatRequest
2412 > }
2413 return nil
2414 }
go.temporal.io/server/chasm/lib/activity/gen/activitypb/v1/activity_state.pb.go 3 introduced LOC · 2 ranges

Open complete file

895 }
896
897 > func (x *ActivityHeartbeatState) GetTotalHeartbeatCount() int64 { activity_state.pb.go
898 > if x != nil {
899 return x.TotalHeartbeatCount
900 }
901 > return 0 activity_state.pb.go
902 }
903