workflow_task_completed_handler.go ×11

Frontier kind: Code frontier

unlabeled · c_c1791fbed431

11 tests · 8775 LOC · 234 files · introduces 0 tests · 66 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
12 ranges66 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1906 ranges8775 lines · 234 files · Browse complete extent
All tests (intent)
11 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: 66 introduced LOC across 12 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/history/api/respondworkflowtaskcompleted/workflow_task_completed_handler.go 62 introduced LOC · 11 ranges

Open complete file

185 }
186 if response != nil {
187 > if response.workflowTaskResponseMutation != nil { workflow_task_completed_handler.go
188 mutations = append(mutations, response.workflowTaskResponseMutation)
189 }
190 > if response.commandPostAction != nil { workflow_task_completed_handler.go
191 postActions = append(postActions, response.commandPostAction)
192 }
288 // all the way down but it requires a bigger refactor of the mutable state interface.
289 switch command.GetCommandType() {
290 > case enumspb.COMMAND_TYPE_SCHEDULE_ACTIVITY_TASK: workflow_task_completed_handler.go
291 > historyEvent, response, err = handler.handleCommandScheduleActivity(ctx, command.GetScheduleActivityTaskCommandAttributes())
292
293 case enumspb.COMMAND_TYPE_COMPLETE_WORKFLOW_EXECUTION:
468 _ context.Context,
469 attr *commandpb.ScheduleActivityTaskCommandAttributes,
470 > ) (*historypb.HistoryEvent, *handleCommandResponse, error) { workflow_task_completed_handler.go
471 > executionInfo := handler.mutableState.GetExecutionInfo()
472 > namespaceID := namespace.ID(executionInfo.NamespaceId)
473 >
474 > // TODO(fairness): remove this again once the SDK allows setting the fairness key
475 > const fairnessKeyPrefix = "x-temporal-internal-fairness-key["
476 > if after, ok := strings.CutPrefix(attr.GetActivityId(), fairnessKeyPrefix); ok {
477 if before, _, ok0 := strings.Cut(after, "]"); ok0 {
478 keyAndWeight := before
488 }
489
490 > if err := handler.validateCommandAttr( workflow_task_completed_handler.go
491 > func() (enumspb.WorkflowTaskFailedCause, error) {
492 > return handler.attrValidator.ValidateActivityScheduleAttributes(
493 > namespaceID,
494 > attr,
495 > executionInfo.WorkflowRunTimeout,
496 > executionInfo.TaskQueue,
497 > )
498 > },
499 ); err != nil || handler.stopProcessing {
500 return nil, nil, err
501 }
502
503 > if handler.mutableState.GetAssignedBuildId() == "" { workflow_task_completed_handler.go
504 > // TODO: this is supported in new versioning [cleanup-old-wv]
505 > if attr.UseWorkflowBuildId && attr.TaskQueue.GetName() != "" && attr.TaskQueue.Name != handler.mutableState.GetExecutionInfo().TaskQueue {
506 err := serviceerror.NewInvalidArgument("Activity with UseCompatibleVersion cannot run on different task queue.")
507 return nil, nil, handler.failWorkflowTask(enumspb.WORKFLOW_TASK_FAILED_CAUSE_BAD_SCHEDULE_ACTIVITY_ATTRIBUTES, err)
509 }
510
511 > metricsHandler := handler.metricsHandler.WithTags(metrics.HeaderCallsiteTag("ScheduleActivityTaskCommand")) workflow_task_completed_handler.go
512 > metrics.HeaderSize.With(metricsHandler).Record(int64(attr.GetHeader().Size()))
513 > if err := handler.sizeLimitChecker.checkIfPayloadSizeExceedsLimit(
514 > metrics.CommandTypeTag(enumspb.COMMAND_TYPE_SCHEDULE_ACTIVITY_TASK.String()),
515 > attr.GetInput().Size(),
516 > "ScheduleActivityTaskCommandAttributes.Input exceeds size limit.",
517 > ); err != nil {
518 return nil, nil, handler.terminateWorkflow(enumspb.WORKFLOW_TASK_FAILED_CAUSE_BAD_SCHEDULE_ACTIVITY_ATTRIBUTES, err)
519 }
520 > if err := handler.sizeLimitChecker.checkIfNumPendingActivitiesExceedsLimit(); err != nil { workflow_task_completed_handler.go
521 return nil, nil, handler.failWorkflowTask(enumspb.WORKFLOW_TASK_FAILED_CAUSE_PENDING_ACTIVITIES_LIMIT_EXCEEDED, err)
522 }
523
524 > enums.SetDefaultTaskQueueKind(&attr.GetTaskQueue().Kind) workflow_task_completed_handler.go
525 >
526 > namespace := handler.mutableState.GetNamespaceEntry().Name().String()
527 >
528 > // TODO: versioning 3 allows eager activity dispatch for both pinned and unpinned workflows, no
529 > // special consideration is need. Remove the versioning logic from here. [cleanup-old-wv]
530 > oldVersioningUsed := handler.mutableState.GetMostRecentWorkerVersionStamp().GetUseVersioning() &&
531 > // for V3 versioning it's ok to dispatch eager activities
532 > handler.mutableState.GetEffectiveVersioningBehavior() == enumspb.VERSIONING_BEHAVIOR_UNSPECIFIED
533 > newVersioningUsed := handler.mutableState.GetExecutionInfo().GetAssignedBuildId() != ""
534 > versioningUsed := oldVersioningUsed || newVersioningUsed
535 >
536 > // Enable eager activity start if dynamic config enables it and either 1. workflow doesn't use versioning,
537 > // or 2. workflow uses versioning and activity intends to use a compatible version (since a
538 > // worker is obviously compatible with itself and we are okay dispatching an eager task knowing that there may be a
539 > // newer "default" compatible version).
540 > // Note that if `UseWorkflowBuildId` is false, it implies that the activity should run on the "default" version
541 > // for the task queue.
542 > eagerStartActivity := attr.RequestEagerExecution && handler.config.EnableActivityEagerExecution(namespace) &&
543 > (!versioningUsed || attr.UseWorkflowBuildId)
544 >
545 > // if the workflow is paused, we bypass activity task generation and also prevent eager activity execution.
546 > bypassActivityTaskGeneration := eagerStartActivity
547 > if handler.mutableState.GetExecutionState().Status == enumspb.WORKFLOW_EXECUTION_STATUS_PAUSED {
548 bypassActivityTaskGeneration = true
549 eagerStartActivity = false
550 }
551
552 > event, _, err := handler.mutableState.AddActivityTaskScheduledEvent( workflow_task_completed_handler.go
553 > handler.workflowTaskCompletedID,
554 > attr,
555 > bypassActivityTaskGeneration,
556 > )
557 > if err != nil {
558 return nil, nil, handler.failWorkflowTaskOnInvalidArgument(enumspb.WORKFLOW_TASK_FAILED_CAUSE_SCHEDULE_ACTIVITY_DUPLICATE_ID, err)
559 }
560
561 > if !eagerStartActivity { workflow_task_completed_handler.go
562 return event, &handleCommandResponse{}, nil
563 }
go.temporal.io/server/api/persistence/v1/executions.pb.go 4 introduced LOC · 1 range

Open complete file

921 }
922
923 > func (x *WorkflowExecutionInfo) GetAssignedBuildId() string { executions.pb.go
924 > if x != nil {
925 > return x.AssignedBuildId
926 > }
927 return ""
928 }