activities.go ×12

Frontier kind: Code frontier

unlabeled · c_0cf7fd4b7437

3 tests · 2904 LOC · 146 files · introduces 0 tests · 40 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
12 ranges40 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
504 ranges2904 lines · 146 files · Browse complete extent
All tests (intent)
3 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.

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

go.temporal.io/server/service/worker/migration/activities.go 40 introduced LOC · 12 ranges

Open complete file

509 targetClusters []string,
510 generateViaFrontend bool,
511 > ) error { activities.go
512 > if err := rateLimiter.WaitN(ctx, 1); err != nil {
513 return err
514 }
515
516 // will generate replication task
517 > ctx, cancel := context.WithTimeout(ctx, time.Second*10) activities.go
518 > defer cancel()
519 >
520 > var stateTransitionCount, historyLength int64
521 > if generateViaFrontend {
522 archetype, err := a.archetypeIDToName(ctx, execution.ArchetypeID)
523 if err != nil {
561 // Take the minimum between StateTransitionCount and HistoryLength as heuristic to avoid unnecessary throttling
562 // in such situation.
563 > count := min(stateTransitionCount, historyLength) activities.go
564 > if a.enableHistoryRateLimiter() {
565 count = max(1, historyLength/largeHistoryLength)
566 }
567 > for count > 0 { activities.go
568 token := min(int(count), rateLimiter.Burst())
569 count -= int64(token)
694 }
695
696 > func (a *activities) GenerateReplicationTasks(ctx context.Context, request *generateReplicationTasksRequest) error { activities.go
697 > ctx = a.setCallerInfoForServerAPI(ctx, namespace.ID(request.NamespaceID))
698 > rateLimiter := quotas.NewRateLimiter(request.RPS, int(math.Ceil(request.RPS)))
699 >
700 > start := time.Now()
701 > defer func() {
702 > a.forceReplicationMetricsHandler.Timer(metrics.GenerateReplicationTasksLatency.Name()).Record(time.Since(start))
703 > }()
704
705 > startIndex := 0 activities.go
706 > if activity.HasHeartbeatDetails(ctx) {
707 if err := activity.GetHeartbeatDetails(ctx, &startIndex); err == nil {
708 startIndex = startIndex + 1 // start from next one
710 }
711
712 > namespaceName, err := a.NamespaceRegistry.GetNamespaceName(namespace.ID(request.NamespaceID)) activities.go
713 > if err != nil {
714 a.Logger.Error("force-replication failed to translate namespaceID to name", tag.WorkflowNamespaceID(request.NamespaceID))
715 return err
716 }
717
718 > generateViaFrontend := a.generateMigrationTaskViaFrontend() activities.go
719 > for i := startIndex; i < len(request.Executions); i++ {
720 > we := request.Executions[i]
721 > if err := a.generateWorkflowReplicationTask(
722 > ctx,
723 > rateLimiter,
724 > namespaceName.String(),
725 > request.NamespaceID,
726 > we,
727 > request.TargetClusters,
728 > generateViaFrontend,
729 > ); err != nil {
730 if !common.IsNotFoundError(err) {
731 a.Logger.Error("force-replication failed to generate replication task",
743 tag.Error(err))
744 }
745 > activity.RecordHeartbeat(ctx, i) activities.go
746 }
747
752 ctx context.Context,
753 namespaceID namespace.ID,
754 > ) context.Context { activities.go
755 > nsName, err := a.NamespaceRegistry.GetNamespaceName(namespaceID)
756 > if err != nil {
757 a.Logger.Error("Failed to get namespace name when generating replication task",
758 tag.WorkflowNamespaceID(namespaceID.String()),
761 nsName = namespace.EmptyName
762 }
763 > return headers.SetCallerInfo(ctx, headers.NewPreemptableCallerInfo(nsName.String())) activities.go
764 }
765