2721
req *matchingservice.PollNexusTaskQueueRequest,
2722
opMetrics metrics.Handler,
2724
>
namespaceID := namespace.ID(req.GetNamespaceId())
2725
>
pollerID := req.GetPollerId()
2726
>
request := req.Request
2727
>
taskQueueName := request.TaskQueue.GetName()
2728
>
ns, err := e.namespaceRegistry.GetNamespaceByID(namespaceID)
2729
>
if err != nil {
2730
return nil, err
2731
}
2733
>
for {
2734
>
err := common.IsValidContext(ctx)
2735
>
if err != nil {
2736
return nil, err
2737
}
2738
// Add frontend generated pollerID to context so taskqueueMgr can support cancellation of
2739
// long-poll when frontend calls CancelOutstandingPoll API
2741
>
pollerCtx = context.WithValue(pollerCtx, identityKey, request.GetIdentity())
2742
>
partition, err := tqid.PartitionFromProto(request.TaskQueue, req.NamespaceId, enumspb.TASK_QUEUE_TYPE_NEXUS)
2743
>
if err != nil {
2744
return nil, err
2745
}
2747
>
workerVersionCapabilities: request.WorkerVersionCapabilities,
2748
>
deploymentOptions: request.DeploymentOptions,
2749
>
forwardedFrom: req.ForwardedSource,
2750
>
conditions: req.Conditions,
2751
>
workerInstanceKey: request.WorkerInstanceKey,
2752
>
}
2753
>
task, _, err := e.pollTask(pollerCtx, partition, pollMetadata)
2754
>
if err != nil {
2755
if errors.Is(err, errNoTasks) {
2756
return &matchingservice.PollNexusTaskQueueResponse{}, nil