workflow.go ×12

Frontier kind: Code frontier

unlabeled · c_a5b00cddf9d0

20 tests · 3211 LOC · 136 files · introduces 0 tests · 66 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
14 ranges66 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
534 ranges3211 lines · 136 files · Browse complete extent
All tests (intent)
20 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 14 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/worker/workerdeployment/workflow.go 52 introduced LOC · 12 ranges

Open complete file

618 }
619
620 > func (d *WorkflowRunner) addVersionToWorkerDeployment(ctx workflow.Context, args *deploymentspb.AddVersionUpdateArgs) error { workflow.go
621 > if d.State.Versions == nil {
622 return nil
623 }
624
625 > for _, k := range workflow.DeterministicKeys(d.State.Versions) { workflow.go
626 > v := d.State.Versions[k]
627 > if v.Version == args.Version {
628 > return nil
629 > }
630 }
631
632 > maxVersions := d.getMaxVersions(ctx) workflow.go
633 >
634 > if len(d.State.Versions) >= maxVersions {
635 err := d.tryDeleteVersion(ctx)
636 if err != nil {
639 }
640
641 > d.State.Versions[args.Version] = &deploymentspb.WorkerDeploymentVersionSummary{ workflow.go
642 > Version: args.Version,
643 > CreateTime: args.CreateTime,
644 > Status: enumspb.WORKER_DEPLOYMENT_VERSION_STATUS_INACTIVE,
645 > }
646 > d.metrics.Counter(metrics.WorkerDeploymentVersionCreated.Name()).Inc(1)
647 > return nil
648 }
649
650 > func (d *WorkflowRunner) handleRegisterWorker(ctx workflow.Context, args *deploymentspb.RegisterWorkerInWorkerDeploymentArgs) error { workflow.go
651 > // TODO: there is a small race condition where the deployment is just deleted and got a register update before closing itself.
652 > // In that case, we should ideally not reject the update, but revive the workflow so that the caller does not need to retry.
653 > // In practice this should be fine because the polls will retry and Deployment workflows are short-lived.
654 > // Same principle applies for Version workflows, but they can be slightly more long-lived of they are handling long propagations.
655 > // Hence, the revive logic is implemented in Version workflow but not here yet.
656 > if err := d.ensureNotDeleted(); err != nil {
657 return err
658 }
659
660 // use lock to enforce only one update at a time
661 > err := d.lock.Lock(ctx) workflow.go
662 > if err != nil {
663 d.logger.Error("Could not acquire workflow lock")
664 return serviceerror.NewDeadlineExceeded("Could not acquire workflow lock")
665 }
666 > defer func() { workflow.go
667 > // Even if the update doesn't change the state we mark it as dirty because of created history events.
668 > d.setStateChanged()
669 > d.lock.Unlock()
670 > }()
671
672 > version := worker_versioning.WorkerDeploymentVersionToStringV31(args.Version) workflow.go
673 >
674 > // Add version to local state of the workflow, if not already present.
675 > err = d.addVersionToWorkerDeployment(ctx, &deploymentspb.AddVersionUpdateArgs{
676 > Version: version,
677 > CreateTime: timestamppb.New(workflow.Now(ctx)),
678 > })
679 > if err != nil {
680 return err
681 }
682 > var routingConfigToSync *deploymentpb.RoutingConfig workflow.go
683 > if d.hasMinVersion(AsyncSetCurrentAndRamping) {
684 routingConfigToSync = d.GetState().GetRoutingConfig()
685 }
686
687 // Register task-queue worker in version workflow.
688 > activityCtx := workflow.WithActivityOptions(ctx, defaultActivityOptions) workflow.go
689 > err = workflow.ExecuteActivity(activityCtx, d.a.RegisterWorkerInVersion, &deploymentspb.RegisterWorkerInVersionArgs{
690 > TaskQueueName: args.TaskQueueName,
691 > TaskQueueType: args.TaskQueueType,
692 > MaxTaskQueues: args.MaxTaskQueues,
693 > Version: version,
694 > RoutingConfig: routingConfigToSync,
695 > }).Get(ctx, nil)
696 > if err != nil {
697 var appError *temporal.ApplicationError
698 if errors.As(err, &appError) {
707 }
708
709 > if d.State.Versions[version].Status == enumspb.WORKER_DEPLOYMENT_VERSION_STATUS_CREATED { workflow.go
710 // now that a poller is seen, we should update the status to INACTIVE
711 d.State.Versions[version].Status = enumspb.WORKER_DEPLOYMENT_VERSION_STATUS_INACTIVE
713
714 // update memo
715 > return d.updateMemo(ctx) workflow.go
716 }
717
go.temporal.io/server/api/deployment/v1/message.pb.go 14 introduced LOC · 2 ranges

Open complete file

1091 }
1092
1093 > func (x *RegisterWorkerInWorkerDeploymentArgs) Reset() { message.pb.go
1094 > *x = RegisterWorkerInWorkerDeploymentArgs{}
1095 > mi := &file_temporal_server_api_deployment_v1_message_proto_msgTypes[11]
1096 > ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
1097 > ms.StoreMessageInfo(mi)
1098 > }
1099
1100 func (x *RegisterWorkerInWorkerDeploymentArgs) String() string {
1104 func (*RegisterWorkerInWorkerDeploymentArgs) ProtoMessage() {}
1105
1106 > func (x *RegisterWorkerInWorkerDeploymentArgs) ProtoReflect() protoreflect.Message { message.pb.go
1107 > mi := &file_temporal_server_api_deployment_v1_message_proto_msgTypes[11]
1108 > if x != nil {
1109 > ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
1110 > if ms.LoadMessageInfo() == nil {
1111 > ms.StoreMessageInfo(mi)
1112 > }
1113 > return ms
1114 }
1115 return mi.MessageOf(x)