Skip to content

Commit 54414e1

Browse files
tconley1428claude
andauthored
Add request header annotation and resource-id fields (#728)
_**READ BEFORE MERGING:** All PRs require approval by both Server AND SDK teams before merging! This is why the number of required approvals is "2" and not "1"--two reviewers from the same team is NOT sufficient. If your PR is not approved by someone in BOTH teams, it may be summarily reverted._ <!-- Describe what has changed in this PR --> Adding a proto annotation to be used for automatically propagating message fields into headers. Will be accompanied by SDK changes to generate code for doing so based on the annotations. See temporalio/api-go#236 and temporalio/sdk-go#2226 for example. Also adds additional `resource-id` fields to a number of messages for use in routing. <!-- Tell your future self why have you made these changes --> MCN support <!-- Are there any breaking changes on binary or code level? --> **Breaking changes** <!-- If this breaks the Server, please provide the Server PR to merge right after this PR was merged. --> **Server PR** --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 8baa851 commit 54414e1

5 files changed

Lines changed: 371 additions & 1 deletion

File tree

openapi/openapiv2.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9183,6 +9183,10 @@
91839183
"selector": {
91849184
"$ref": "#/definitions/v1WorkerSelector",
91859185
"description": "Defines which workers should receive this command.\nonly single worker is supported at this time."
9186+
},
9187+
"resourceId": {
9188+
"type": "string",
9189+
"description": "Resource ID for routing. Contains the worker grouping key."
91869190
}
91879191
}
91889192
},
@@ -9296,6 +9300,10 @@
92969300
"identity": {
92979301
"type": "string",
92989302
"title": "The identity of the worker/client"
9303+
},
9304+
"resourceId": {
9305+
"type": "string",
9306+
"description": "Resource ID for routing. Contains the workflow ID or activity ID for standalone activities."
92999307
}
93009308
}
93019309
},
@@ -9313,6 +9321,10 @@
93139321
"identity": {
93149322
"type": "string",
93159323
"title": "The identity of the worker/client"
9324+
},
9325+
"resourceId": {
9326+
"type": "string",
9327+
"description": "Resource ID for routing. Contains \"workflow:workflow_id\" or \"activity:activity_id\" for standalone activities."
93169328
}
93179329
}
93189330
},
@@ -9329,6 +9341,10 @@
93299341
"type": "object",
93309342
"$ref": "#/definitions/v1WorkerHeartbeat"
93319343
}
9344+
},
9345+
"resourceId": {
9346+
"type": "string",
9347+
"description": "Resource ID for routing. Contains the worker grouping key."
93329348
}
93339349
}
93349350
},
@@ -9498,6 +9514,10 @@
94989514
"type": "string",
94999515
"title": "The identity of the worker/client"
95009516
},
9517+
"resourceId": {
9518+
"type": "string",
9519+
"description": "Resource ID for routing. Contains the workflow ID or activity ID for standalone activities."
9520+
},
95019521
"workerVersion": {
95029522
"$ref": "#/definitions/v1WorkerVersionStamp",
95039523
"description": "Version info of the worker who processed this task. This message's `build_id` field should\nalways be set by SDKs. Workers opting into versioning will also set the `use_versioning`\nfield to true. See message docstrings for more.\nDeprecated. Use `deployment_options` instead."
@@ -9530,6 +9550,10 @@
95309550
"deploymentOptions": {
95319551
"$ref": "#/definitions/v1WorkerDeploymentOptions",
95329552
"description": "Worker deployment options that user has set in the worker."
9553+
},
9554+
"resourceId": {
9555+
"type": "string",
9556+
"description": "Resource ID for routing. Contains \"workflow:workflow_id\" or \"activity:activity_id\" for standalone activities."
95339557
}
95349558
}
95359559
},
@@ -9549,6 +9573,10 @@
95499573
"type": "string",
95509574
"title": "The identity of the worker/client"
95519575
},
9576+
"resourceId": {
9577+
"type": "string",
9578+
"description": "Resource ID for routing. Contains the workflow ID or activity ID for standalone activities."
9579+
},
95529580
"workerVersion": {
95539581
"$ref": "#/definitions/v1WorkerVersionStamp",
95549582
"description": "Version info of the worker who processed this task. This message's `build_id` field should\nalways be set by SDKs. Workers opting into versioning will also set the `use_versioning`\nfield to true. See message docstrings for more.\nDeprecated. Use `deployment_options` instead."
@@ -9577,6 +9605,10 @@
95779605
"identity": {
95789606
"type": "string",
95799607
"title": "The identity of the worker/client"
9608+
},
9609+
"resourceId": {
9610+
"type": "string",
9611+
"description": "Resource ID for routing. Contains \"workflow:workflow_id\" or \"activity:activity_id\" for standalone activities."
95809612
}
95819613
}
95829614
},
@@ -9596,6 +9628,10 @@
95969628
"type": "string",
95979629
"title": "The identity of the worker/client"
95989630
},
9631+
"resourceId": {
9632+
"type": "string",
9633+
"description": "Resource ID for routing. Contains the workflow ID or activity ID for standalone activities."
9634+
},
95999635
"lastHeartbeatDetails": {
96009636
"$ref": "#/definitions/v1Payloads",
96019637
"title": "Additional details to be stored as last activity heartbeat"
@@ -9632,6 +9668,10 @@
96329668
"lastHeartbeatDetails": {
96339669
"$ref": "#/definitions/v1Payloads",
96349670
"title": "Additional details to be stored as last activity heartbeat"
9671+
},
9672+
"resourceId": {
9673+
"type": "string",
9674+
"description": "Resource ID for routing. Contains \"workflow:workflow_id\" or \"activity:activity_id\" for standalone activities."
96359675
}
96369676
}
96379677
},
@@ -10416,6 +10456,10 @@
1041610456
"selector": {
1041710457
"$ref": "#/definitions/v1WorkerSelector",
1041810458
"description": "Defines which workers should receive this command."
10459+
},
10460+
"resourceId": {
10461+
"type": "string",
10462+
"description": "Resource ID for routing. Contains the worker grouping key."
1041910463
}
1042010464
}
1042110465
},

openapi/openapiv3.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9851,6 +9851,9 @@ components:
98519851
description: |-
98529852
Defines which workers should receive this command.
98539853
only single worker is supported at this time.
9854+
resourceId:
9855+
type: string
9856+
description: Resource ID for routing. Contains the worker grouping key.
98549857
FetchWorkerConfigResponse:
98559858
type: object
98569859
properties:
@@ -11919,6 +11922,9 @@ components:
1191911922
identity:
1192011923
type: string
1192111924
description: The identity of the worker/client
11925+
resourceId:
11926+
type: string
11927+
description: Resource ID for routing. Contains "workflow:workflow_id" or "activity:activity_id" for standalone activities.
1192211928
RecordActivityTaskHeartbeatByIdResponse:
1192311929
type: object
1192411930
properties:
@@ -11951,6 +11957,9 @@ components:
1195111957
description: The identity of the worker/client
1195211958
namespace:
1195311959
type: string
11960+
resourceId:
11961+
type: string
11962+
description: Resource ID for routing. Contains the workflow ID or activity ID for standalone activities.
1195411963
RecordActivityTaskHeartbeatResponse:
1195511964
type: object
1195611965
properties:
@@ -11980,6 +11989,9 @@ components:
1198011989
type: array
1198111990
items:
1198211991
$ref: '#/components/schemas/WorkerHeartbeat'
11992+
resourceId:
11993+
type: string
11994+
description: Resource ID for routing. Contains the worker grouping key.
1198311995
RecordWorkerHeartbeatResponse:
1198411996
type: object
1198511997
properties: {}
@@ -12469,6 +12481,9 @@ components:
1246912481
allOf:
1247012482
- $ref: '#/components/schemas/WorkerDeploymentOptions'
1247112483
description: Worker deployment options that user has set in the worker.
12484+
resourceId:
12485+
type: string
12486+
description: Resource ID for routing. Contains "workflow:workflow_id" or "activity:activity_id" for standalone activities.
1247212487
RespondActivityTaskCanceledByIdResponse:
1247312488
type: object
1247412489
properties: {}
@@ -12488,6 +12503,9 @@ components:
1248812503
description: The identity of the worker/client
1248912504
namespace:
1249012505
type: string
12506+
resourceId:
12507+
type: string
12508+
description: Resource ID for routing. Contains the workflow ID or activity ID for standalone activities.
1249112509
workerVersion:
1249212510
allOf:
1249312511
- $ref: '#/components/schemas/WorkerVersionStamp'
@@ -12534,6 +12552,9 @@ components:
1253412552
identity:
1253512553
type: string
1253612554
description: The identity of the worker/client
12555+
resourceId:
12556+
type: string
12557+
description: Resource ID for routing. Contains "workflow:workflow_id" or "activity:activity_id" for standalone activities.
1253712558
RespondActivityTaskCompletedByIdResponse:
1253812559
type: object
1253912560
properties: {}
@@ -12553,6 +12574,9 @@ components:
1255312574
description: The identity of the worker/client
1255412575
namespace:
1255512576
type: string
12577+
resourceId:
12578+
type: string
12579+
description: Resource ID for routing. Contains the workflow ID or activity ID for standalone activities.
1255612580
workerVersion:
1255712581
allOf:
1255812582
- $ref: '#/components/schemas/WorkerVersionStamp'
@@ -12603,6 +12627,9 @@ components:
1260312627
allOf:
1260412628
- $ref: '#/components/schemas/Payloads'
1260512629
description: Additional details to be stored as last activity heartbeat
12630+
resourceId:
12631+
type: string
12632+
description: Resource ID for routing. Contains "workflow:workflow_id" or "activity:activity_id" for standalone activities.
1260612633
RespondActivityTaskFailedByIdResponse:
1260712634
type: object
1260812635
properties:
@@ -12629,6 +12656,9 @@ components:
1262912656
description: The identity of the worker/client
1263012657
namespace:
1263112658
type: string
12659+
resourceId:
12660+
type: string
12661+
description: Resource ID for routing. Contains the workflow ID or activity ID for standalone activities.
1263212662
lastHeartbeatDetails:
1263312663
allOf:
1263412664
- $ref: '#/components/schemas/Payloads'
@@ -14841,6 +14871,9 @@ components:
1484114871
allOf:
1484214872
- $ref: '#/components/schemas/WorkerSelector'
1484314873
description: Defines which workers should receive this command.
14874+
resourceId:
14875+
type: string
14876+
description: Resource ID for routing. Contains the worker grouping key.
1484414877
UpdateWorkerConfigResponse:
1484514878
type: object
1484614879
properties:
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
syntax = "proto3";
2+
3+
package temporal.api.protometa.v1;
4+
5+
option go_package = "go.temporal.io/api/protometa/v1;protometa";
6+
option java_package = "io.temporal.api.protometa.v1";
7+
option java_multiple_files = true;
8+
option java_outer_classname = "AnnotationsProto";
9+
option ruby_package = "Temporalio::Api::Protometa::V1";
10+
option csharp_namespace = "Temporalio.Api.Protometa.V1";
11+
12+
import "google/protobuf/descriptor.proto";
13+
14+
// RequestHeaderAnnotation allows specifying that field values from a request
15+
// should be propagated as outbound headers.
16+
//
17+
// The value field supports template interpolation where field paths enclosed
18+
// in braces will be replaced with the actual field values from the request.
19+
// For example:
20+
// value: "{workflow_execution.workflow_id}"
21+
// value: "workflow-{workflow_execution.workflow_id}"
22+
// value: "{namespace}/{workflow_execution.workflow_id}"
23+
message RequestHeaderAnnotation {
24+
// The name of the header to set (e.g., "temporal-resource-id")
25+
string header = 1;
26+
27+
// A template string that may contain field paths in braces.
28+
// Field paths use dot notation to traverse nested messages.
29+
// Example: "{workflow_execution.workflow_id}"
30+
string value = 2;
31+
}
32+
33+
// Extension to add request-header annotations to RPC methods.
34+
// Multiple headers can be set by repeating this option.
35+
extend google.protobuf.MethodOptions {
36+
repeated RequestHeaderAnnotation request_header = 7234001;
37+
}

temporal/api/workflowservice/v1/request_response.proto

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,8 @@ message RespondWorkflowTaskCompletedRequest {
357357
// Responses to the `queries` field in the task being responded to
358358
map<string, temporal.api.query.v1.WorkflowQueryResult> query_results = 8;
359359
string namespace = 9;
360+
// Resource ID for routing. Contains the workflow ID from the original task.
361+
string resource_id = 18;
360362
// Version info of the worker who processed this task. This message's `build_id` field should
361363
// always be set by SDKs. Workers opting into versioning will also set the `use_versioning`
362364
// field to true. See message docstrings for more.
@@ -418,6 +420,8 @@ message RespondWorkflowTaskFailedRequest {
418420
// Worker process' unique binary id
419421
string binary_checksum = 5 [deprecated = true];
420422
string namespace = 6;
423+
// Resource ID for routing. Contains the workflow ID from the original task.
424+
string resource_id = 11;
421425
// Protocol messages piggybacking on a WFT as a transport
422426
repeated temporal.api.protocol.v1.Message messages = 7;
423427
// Version info of the worker who processed this task. This message's `build_id` field should
@@ -522,6 +526,8 @@ message RecordActivityTaskHeartbeatRequest {
522526
// The identity of the worker/client
523527
string identity = 3;
524528
string namespace = 4;
529+
// Resource ID for routing. Contains the workflow ID or activity ID for standalone activities.
530+
string resource_id = 5;
525531
}
526532

527533
message RecordActivityTaskHeartbeatResponse {
@@ -551,6 +557,8 @@ message RecordActivityTaskHeartbeatByIdRequest {
551557
temporal.api.common.v1.Payloads details = 5;
552558
// The identity of the worker/client
553559
string identity = 6;
560+
// Resource ID for routing. Contains "workflow:workflow_id" or "activity:activity_id" for standalone activities.
561+
string resource_id = 7;
554562
}
555563

556564
message RecordActivityTaskHeartbeatByIdResponse {
@@ -574,6 +582,8 @@ message RespondActivityTaskCompletedRequest {
574582
// The identity of the worker/client
575583
string identity = 3;
576584
string namespace = 4;
585+
// Resource ID for routing. Contains the workflow ID or activity ID for standalone activities.
586+
string resource_id = 8;
577587
// Version info of the worker who processed this task. This message's `build_id` field should
578588
// always be set by SDKs. Workers opting into versioning will also set the `use_versioning`
579589
// field to true. See message docstrings for more.
@@ -604,6 +614,8 @@ message RespondActivityTaskCompletedByIdRequest {
604614
temporal.api.common.v1.Payloads result = 5;
605615
// The identity of the worker/client
606616
string identity = 6;
617+
// Resource ID for routing. Contains "workflow:workflow_id" or "activity:activity_id" for standalone activities.
618+
string resource_id = 7;
607619
}
608620

609621
message RespondActivityTaskCompletedByIdResponse {
@@ -617,6 +629,8 @@ message RespondActivityTaskFailedRequest {
617629
// The identity of the worker/client
618630
string identity = 3;
619631
string namespace = 4;
632+
// Resource ID for routing. Contains the workflow ID or activity ID for standalone activities.
633+
string resource_id = 9;
620634
// Additional details to be stored as last activity heartbeat
621635
temporal.api.common.v1.Payloads last_heartbeat_details = 5;
622636
// Version info of the worker who processed this task. This message's `build_id` field should
@@ -654,6 +668,8 @@ message RespondActivityTaskFailedByIdRequest {
654668
string identity = 6;
655669
// Additional details to be stored as last activity heartbeat
656670
temporal.api.common.v1.Payloads last_heartbeat_details = 7;
671+
// Resource ID for routing. Contains "workflow:workflow_id" or "activity:activity_id" for standalone activities.
672+
string resource_id = 8;
657673
}
658674

659675
message RespondActivityTaskFailedByIdResponse {
@@ -670,6 +686,8 @@ message RespondActivityTaskCanceledRequest {
670686
// The identity of the worker/client
671687
string identity = 3;
672688
string namespace = 4;
689+
// Resource ID for routing. Contains the workflow ID or activity ID for standalone activities.
690+
string resource_id = 8;
673691
// Version info of the worker who processed this task. This message's `build_id` field should
674692
// always be set by SDKs. Workers opting into versioning will also set the `use_versioning`
675693
// field to true. See message docstrings for more.
@@ -702,6 +720,8 @@ message RespondActivityTaskCanceledByIdRequest {
702720
string identity = 6;
703721
// Worker deployment options that user has set in the worker.
704722
temporal.api.deployment.v1.WorkerDeploymentOptions deployment_options = 7;
723+
// Resource ID for routing. Contains "workflow:workflow_id" or "activity:activity_id" for standalone activities.
724+
string resource_id = 8;
705725
}
706726

707727
message RespondActivityTaskCanceledByIdResponse {
@@ -1915,6 +1935,9 @@ message ExecuteMultiOperationRequest {
19151935
// Note that additional operation-specific restrictions have to be considered.
19161936
repeated Operation operations = 2;
19171937

1938+
// Resource ID for routing. Should match operations[0].start_workflow.workflow_id
1939+
string resource_id = 3;
1940+
19181941
message Operation {
19191942
oneof operation {
19201943
// Additional restrictions:
@@ -2549,6 +2572,9 @@ message RecordWorkerHeartbeatRequest {
25492572
string identity = 2;
25502573

25512574
repeated temporal.api.worker.v1.WorkerHeartbeat worker_heartbeat = 3;
2575+
2576+
// Resource ID for routing. Contains the worker grouping key.
2577+
string resource_id = 4;
25522578
}
25532579

25542580
message RecordWorkerHeartbeatResponse {
@@ -2635,6 +2661,8 @@ message FetchWorkerConfigRequest {
26352661
// Defines which workers should receive this command.
26362662
// only single worker is supported at this time.
26372663
temporal.api.common.v1.WorkerSelector selector = 6;
2664+
// Resource ID for routing. Contains the worker grouping key.
2665+
string resource_id = 7;
26382666
}
26392667

26402668
message FetchWorkerConfigResponse {
@@ -2661,6 +2689,8 @@ message UpdateWorkerConfigRequest {
26612689

26622690
// Defines which workers should receive this command.
26632691
temporal.api.common.v1.WorkerSelector selector = 6;
2692+
// Resource ID for routing. Contains the worker grouping key.
2693+
string resource_id = 7;
26642694
}
26652695

26662696
message UpdateWorkerConfigResponse {

0 commit comments

Comments
 (0)