workflow_handler.go ×9

Frontier kind: Code frontier

unlabeled · c_4b3c3bc17b6b

2 tests · 3960 LOC · 199 files · introduces 0 tests · 54 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
9 ranges54 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
592 ranges3960 lines · 199 files · Browse complete extent
All tests (intent)
2 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: 54 introduced LOC across 9 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/frontend/workflow_handler.go 54 introduced LOC · 9 ranges

Open complete file

3016 wh.cancelOutstandingWorkerPolls(ctx, namespaceID.String(), request)
3017 } else {
3018 > wh.cancelOutstandingWorkerPollsFrontendFanout(ctx, namespaceID.String(), request) workflow_handler.go
3019 > }
3020 })
3021 }
3127 namespaceID string,
3128 request *workflowservice.ShutdownWorkerRequest,
3129 > ) { workflow_handler.go
3130 > workerInstanceKey := request.GetWorkerInstanceKey()
3131 > taskQueueName := request.GetTaskQueue()
3132 > if workerInstanceKey == "" || taskQueueName == "" {
3133 return
3134 }
3135
3136 > namespaceName := request.GetNamespace() workflow_handler.go
3137 >
3138 > taskTypes := request.GetTaskQueueTypes()
3139 > if len(taskTypes) == 0 {
3140 > taskTypes = []enumspb.TaskQueueType{
3141 > enumspb.TASK_QUEUE_TYPE_WORKFLOW,
3142 > enumspb.TASK_QUEUE_TYPE_ACTIVITY,
3143 > }
3144 > }
3145
3146 > tqFamily, err := tqid.NewTaskQueueFamily(namespaceID, taskQueueName) workflow_handler.go
3147 > if err != nil {
3148 wh.logger.Warn("Invalid task queue name for poll cancellation.",
3149 tag.WorkflowTaskQueueName(taskQueueName),
3156 // regardless of partition. Sending one RPC per host instead of one per partition reduces
3157 // RPCs from numPartitions*taskTypes to numHosts*taskTypes.
3158 > routingClient, ok := wh.matchingClient.(matchingclient.RoutingClient) workflow_handler.go
3159 > if !ok {
3160 routingClient = nil
3161 }
3162
3163 > var waitGroup sync.WaitGroup workflow_handler.go
3164 > var totalCancelled atomic.Int32
3165 > var failedPartitions atomic.Int32
3166 >
3167 > for _, taskType := range taskTypes {
3168 > numPartitions := max(wh.config.NumTaskQueueReadPartitions(namespaceName, taskQueueName, taskType), 1)
3169 >
3170 > tq := tqFamily.TaskQueue(taskType)
3171 > // Skip partitions that route to an already-visited matching host.
3172 > seenHosts := make(map[string]bool)
3173 > for partitionID := range numPartitions {
3174 > partition := tq.NormalPartition(partitionID)
3175 >
3176 > if routingClient != nil {
3177 host, err := routingClient.Route(partition)
3178 if err != nil {
3188 }
3189
3190 > waitGroup.Go(func() { workflow_handler.go
3191 > resp, err := wh.matchingClient.CancelOutstandingWorkerPolls(ctx, &matchingservice.CancelOutstandingWorkerPollsRequest{
3192 > NamespaceId: namespaceID,
3193 > TaskQueue: &taskqueuepb.TaskQueue{
3194 > Name: partition.RpcName(),
3195 > Kind: enumspb.TASK_QUEUE_KIND_NORMAL,
3196 > },
3197 > TaskQueueType: taskType,
3198 > WorkerInstanceKey: workerInstanceKey,
3199 > WorkerIdentity: request.GetIdentity(),
3200 > })
3201 > if err != nil {
3202 failedPartitions.Add(1)
3203 wh.logger.Warn("Failed to cancel outstanding polls for worker.",
3205 tag.String("worker-instance-key", workerInstanceKey),
3206 tag.Error(err))
3207 > } else { workflow_handler.go
3208 > totalCancelled.Add(resp.CancelledCount)
3209 > }
3210 })
3211 }
3212 }
3213 > waitGroup.Wait() workflow_handler.go
3214 >
3215 > wh.logger.Debug("Cancelled outstanding polls for worker shutdown.",
3216 > tag.String("worker-instance-key", workerInstanceKey),
3217 > tag.NewInt32("cancelled-count", totalCancelled.Load()),
3218 > tag.NewInt32("failed-partitions", failedPartitions.Load()))
3219 }
3220