Skip to content

Commit aadf2e8

Browse files
Expose Nexus Endpoint in Nexus Info (temporalio#2291)
1 parent 8167351 commit aadf2e8

4 files changed

Lines changed: 10 additions & 2 deletions

File tree

internal/internal_nexus_task_handler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ func (h *nexusTaskHandler) newNexusOperationContext(response *workflowservice.Po
450450

451451
return &NexusOperationContext{
452452
client: h.client,
453+
Endpoint: response.GetRequest().GetEndpoint(),
453454
Namespace: h.namespace,
454455
TaskQueue: h.taskQueueName,
455456
metricsHandler: metricsHandler,

internal/internal_workflow_testsuite.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3568,6 +3568,7 @@ func (h *testNexusOperationHandle) newStartTask() *workflowservice.PollNexusTask
35683568
Request: &nexuspb.Request{
35693569
ScheduledTime: timestamppb.Now(),
35703570
Header: h.params.nexusHeader,
3571+
Endpoint: h.params.client.Endpoint(),
35713572
Capabilities: &nexuspb.Request_Capabilities{
35723573
TemporalFailureResponses: true,
35733574
},
@@ -3595,6 +3596,7 @@ func (h *testNexusOperationHandle) newCancelTask() *workflowservice.PollNexusTas
35953596
Request: &nexuspb.Request{
35963597
ScheduledTime: timestamppb.Now(),
35973598
Header: h.params.nexusHeader,
3599+
Endpoint: h.params.client.Endpoint(),
35983600
Capabilities: &nexuspb.Request_Capabilities{
35993601
TemporalFailureResponses: true,
36003602
},

internal/nexus_operations.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@ type NexusOperationInfo struct {
2828
Namespace string
2929
// The task queue of the worker handling this Nexus operation.
3030
TaskQueue string
31+
// The endpoint this request was addressed to before forwarding to the worker.
32+
// Supported from server version 1.30.0.
33+
Endpoint string
3134
}
3235

3336
// NexusOperationContext is an internal only struct that holds fields used by the temporalnexus functions.
3437
type NexusOperationContext struct {
3538
client Client
3639
Namespace string
3740
TaskQueue string
41+
Endpoint string
3842
metricsHandler metrics.Handler
3943
log log.Logger
4044
registry *registry
@@ -54,6 +58,7 @@ func (nc *nexusOperationEnvironment) GetOperationInfo(ctx context.Context) Nexus
5458
panic("temporalnexus GetInfo: Not a valid Nexus context")
5559
}
5660
return NexusOperationInfo{
61+
Endpoint: nctx.Endpoint,
5762
Namespace: nctx.Namespace,
5863
TaskQueue: nctx.TaskQueue,
5964
}

test/nexus_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ func TestOperationInfo(t *testing.T) {
548548

549549
op := nexus.NewSyncOperation("op", func(ctx context.Context, outcome string, o nexus.StartOperationOptions) (string, error) {
550550
info := temporalnexus.GetOperationInfo(ctx)
551-
return info.Namespace + ":" + info.TaskQueue, nil
551+
return info.Endpoint + ":" + info.Namespace + ":" + info.TaskQueue, nil
552552
})
553553

554554
wf := func(ctx workflow.Context, outcome string) (string, error) {
@@ -586,7 +586,7 @@ func TestOperationInfo(t *testing.T) {
586586
require.NoError(t, err)
587587
var result string
588588
require.NoError(t, run.Get(ctx, &result))
589-
require.Equal(t, tc.testConfig.Namespace+":"+tc.taskQueue, result)
589+
require.Equal(t, tc.endpoint+":"+tc.testConfig.Namespace+":"+tc.taskQueue, result)
590590
}
591591

592592
func TestSyncOperationFromWorkflow(t *testing.T) {

0 commit comments

Comments
 (0)