Skip to content

Commit db60de4

Browse files
tconley1428claude
authored andcommitted
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 9ab9630 commit db60de4

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
@@ -9902,6 +9902,10 @@
99029902
"selector": {
99039903
"$ref": "#/definitions/v1WorkerSelector",
99049904
"description": "Defines which workers should receive this command.\nonly single worker is supported at this time."
9905+
},
9906+
"resourceId": {
9907+
"type": "string",
9908+
"description": "Resource ID for routing. Contains the worker grouping key."
99059909
}
99069910
}
99079911
},
@@ -10015,6 +10019,10 @@
1001510019
"identity": {
1001610020
"type": "string",
1001710021
"title": "The identity of the worker/client"
10022+
},
10023+
"resourceId": {
10024+
"type": "string",
10025+
"description": "Resource ID for routing. Contains the workflow ID or activity ID for standalone activities."
1001810026
}
1001910027
}
1002010028
},
@@ -10032,6 +10040,10 @@
1003210040
"identity": {
1003310041
"type": "string",
1003410042
"title": "The identity of the worker/client"
10043+
},
10044+
"resourceId": {
10045+
"type": "string",
10046+
"description": "Resource ID for routing. Contains \"workflow:workflow_id\" or \"activity:activity_id\" for standalone activities."
1003510047
}
1003610048
}
1003710049
},
@@ -10048,6 +10060,10 @@
1004810060
"type": "object",
1004910061
"$ref": "#/definitions/v1WorkerHeartbeat"
1005010062
}
10063+
},
10064+
"resourceId": {
10065+
"type": "string",
10066+
"description": "Resource ID for routing. Contains the worker grouping key."
1005110067
}
1005210068
}
1005310069
},
@@ -10238,6 +10254,10 @@
1023810254
"type": "string",
1023910255
"title": "The identity of the worker/client"
1024010256
},
10257+
"resourceId": {
10258+
"type": "string",
10259+
"description": "Resource ID for routing. Contains the workflow ID or activity ID for standalone activities."
10260+
},
1024110261
"workerVersion": {
1024210262
"$ref": "#/definitions/v1WorkerVersionStamp",
1024310263
"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."
@@ -10270,6 +10290,10 @@
1027010290
"deploymentOptions": {
1027110291
"$ref": "#/definitions/v1WorkerDeploymentOptions",
1027210292
"description": "Worker deployment options that user has set in the worker."
10293+
},
10294+
"resourceId": {
10295+
"type": "string",
10296+
"description": "Resource ID for routing. Contains \"workflow:workflow_id\" or \"activity:activity_id\" for standalone activities."
1027310297
}
1027410298
}
1027510299
},
@@ -10289,6 +10313,10 @@
1028910313
"type": "string",
1029010314
"title": "The identity of the worker/client"
1029110315
},
10316+
"resourceId": {
10317+
"type": "string",
10318+
"description": "Resource ID for routing. Contains the workflow ID or activity ID for standalone activities."
10319+
},
1029210320
"workerVersion": {
1029310321
"$ref": "#/definitions/v1WorkerVersionStamp",
1029410322
"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."
@@ -10317,6 +10345,10 @@
1031710345
"identity": {
1031810346
"type": "string",
1031910347
"title": "The identity of the worker/client"
10348+
},
10349+
"resourceId": {
10350+
"type": "string",
10351+
"description": "Resource ID for routing. Contains \"workflow:workflow_id\" or \"activity:activity_id\" for standalone activities."
1032010352
}
1032110353
}
1032210354
},
@@ -10336,6 +10368,10 @@
1033610368
"type": "string",
1033710369
"title": "The identity of the worker/client"
1033810370
},
10371+
"resourceId": {
10372+
"type": "string",
10373+
"description": "Resource ID for routing. Contains the workflow ID or activity ID for standalone activities."
10374+
},
1033910375
"lastHeartbeatDetails": {
1034010376
"$ref": "#/definitions/v1Payloads",
1034110377
"title": "Additional details to be stored as last activity heartbeat"
@@ -10372,6 +10408,10 @@
1037210408
"lastHeartbeatDetails": {
1037310409
"$ref": "#/definitions/v1Payloads",
1037410410
"title": "Additional details to be stored as last activity heartbeat"
10411+
},
10412+
"resourceId": {
10413+
"type": "string",
10414+
"description": "Resource ID for routing. Contains \"workflow:workflow_id\" or \"activity:activity_id\" for standalone activities."
1037510415
}
1037610416
}
1037710417
},
@@ -11233,6 +11273,10 @@
1123311273
"selector": {
1123411274
"$ref": "#/definitions/v1WorkerSelector",
1123511275
"description": "Defines which workers should receive this command."
11276+
},
11277+
"resourceId": {
11278+
"type": "string",
11279+
"description": "Resource ID for routing. Contains the worker grouping key."
1123611280
}
1123711281
}
1123811282
},

openapi/openapiv3.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10548,6 +10548,9 @@ components:
1054810548
description: |-
1054910549
Defines which workers should receive this command.
1055010550
only single worker is supported at this time.
10551+
resourceId:
10552+
type: string
10553+
description: Resource ID for routing. Contains the worker grouping key.
1055110554
FetchWorkerConfigResponse:
1055210555
type: object
1055310556
properties:
@@ -12857,6 +12860,9 @@ components:
1285712860
identity:
1285812861
type: string
1285912862
description: The identity of the worker/client
12863+
resourceId:
12864+
type: string
12865+
description: Resource ID for routing. Contains "workflow:workflow_id" or "activity:activity_id" for standalone activities.
1286012866
RecordActivityTaskHeartbeatByIdResponse:
1286112867
type: object
1286212868
properties:
@@ -12889,6 +12895,9 @@ components:
1288912895
description: The identity of the worker/client
1289012896
namespace:
1289112897
type: string
12898+
resourceId:
12899+
type: string
12900+
description: Resource ID for routing. Contains the workflow ID or activity ID for standalone activities.
1289212901
RecordActivityTaskHeartbeatResponse:
1289312902
type: object
1289412903
properties:
@@ -12918,6 +12927,9 @@ components:
1291812927
type: array
1291912928
items:
1292012929
$ref: '#/components/schemas/WorkerHeartbeat'
12930+
resourceId:
12931+
type: string
12932+
description: Resource ID for routing. Contains the worker grouping key.
1292112933
RecordWorkerHeartbeatResponse:
1292212934
type: object
1292312935
properties: {}
@@ -13429,6 +13441,9 @@ components:
1342913441
allOf:
1343013442
- $ref: '#/components/schemas/WorkerDeploymentOptions'
1343113443
description: Worker deployment options that user has set in the worker.
13444+
resourceId:
13445+
type: string
13446+
description: Resource ID for routing. Contains "workflow:workflow_id" or "activity:activity_id" for standalone activities.
1343213447
RespondActivityTaskCanceledByIdResponse:
1343313448
type: object
1343413449
properties: {}
@@ -13448,6 +13463,9 @@ components:
1344813463
description: The identity of the worker/client
1344913464
namespace:
1345013465
type: string
13466+
resourceId:
13467+
type: string
13468+
description: Resource ID for routing. Contains the workflow ID or activity ID for standalone activities.
1345113469
workerVersion:
1345213470
allOf:
1345313471
- $ref: '#/components/schemas/WorkerVersionStamp'
@@ -13494,6 +13512,9 @@ components:
1349413512
identity:
1349513513
type: string
1349613514
description: The identity of the worker/client
13515+
resourceId:
13516+
type: string
13517+
description: Resource ID for routing. Contains "workflow:workflow_id" or "activity:activity_id" for standalone activities.
1349713518
RespondActivityTaskCompletedByIdResponse:
1349813519
type: object
1349913520
properties: {}
@@ -13513,6 +13534,9 @@ components:
1351313534
description: The identity of the worker/client
1351413535
namespace:
1351513536
type: string
13537+
resourceId:
13538+
type: string
13539+
description: Resource ID for routing. Contains the workflow ID or activity ID for standalone activities.
1351613540
workerVersion:
1351713541
allOf:
1351813542
- $ref: '#/components/schemas/WorkerVersionStamp'
@@ -13563,6 +13587,9 @@ components:
1356313587
allOf:
1356413588
- $ref: '#/components/schemas/Payloads'
1356513589
description: Additional details to be stored as last activity heartbeat
13590+
resourceId:
13591+
type: string
13592+
description: Resource ID for routing. Contains "workflow:workflow_id" or "activity:activity_id" for standalone activities.
1356613593
RespondActivityTaskFailedByIdResponse:
1356713594
type: object
1356813595
properties:
@@ -13589,6 +13616,9 @@ components:
1358913616
description: The identity of the worker/client
1359013617
namespace:
1359113618
type: string
13619+
resourceId:
13620+
type: string
13621+
description: Resource ID for routing. Contains the workflow ID or activity ID for standalone activities.
1359213622
lastHeartbeatDetails:
1359313623
allOf:
1359413624
- $ref: '#/components/schemas/Payloads'
@@ -15912,6 +15942,9 @@ components:
1591215942
allOf:
1591315943
- $ref: '#/components/schemas/WorkerSelector'
1591415944
description: Defines which workers should receive this command.
15945+
resourceId:
15946+
type: string
15947+
description: Resource ID for routing. Contains the worker grouping key.
1591515948
UpdateWorkerConfigResponse:
1591615949
type: object
1591715950
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
@@ -358,6 +358,8 @@ message RespondWorkflowTaskCompletedRequest {
358358
// Responses to the `queries` field in the task being responded to
359359
map<string, temporal.api.query.v1.WorkflowQueryResult> query_results = 8;
360360
string namespace = 9;
361+
// Resource ID for routing. Contains the workflow ID from the original task.
362+
string resource_id = 18;
361363
// Version info of the worker who processed this task. This message's `build_id` field should
362364
// always be set by SDKs. Workers opting into versioning will also set the `use_versioning`
363365
// field to true. See message docstrings for more.
@@ -419,6 +421,8 @@ message RespondWorkflowTaskFailedRequest {
419421
// Worker process' unique binary id
420422
string binary_checksum = 5 [deprecated = true];
421423
string namespace = 6;
424+
// Resource ID for routing. Contains the workflow ID from the original task.
425+
string resource_id = 11;
422426
// Protocol messages piggybacking on a WFT as a transport
423427
repeated temporal.api.protocol.v1.Message messages = 7;
424428
// Version info of the worker who processed this task. This message's `build_id` field should
@@ -523,6 +527,8 @@ message RecordActivityTaskHeartbeatRequest {
523527
// The identity of the worker/client
524528
string identity = 3;
525529
string namespace = 4;
530+
// Resource ID for routing. Contains the workflow ID or activity ID for standalone activities.
531+
string resource_id = 5;
526532
}
527533

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

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

610622
message RespondActivityTaskCompletedByIdResponse {
@@ -618,6 +630,8 @@ message RespondActivityTaskFailedRequest {
618630
// The identity of the worker/client
619631
string identity = 3;
620632
string namespace = 4;
633+
// Resource ID for routing. Contains the workflow ID or activity ID for standalone activities.
634+
string resource_id = 9;
621635
// Additional details to be stored as last activity heartbeat
622636
temporal.api.common.v1.Payloads last_heartbeat_details = 5;
623637
// Version info of the worker who processed this task. This message's `build_id` field should
@@ -655,6 +669,8 @@ message RespondActivityTaskFailedByIdRequest {
655669
string identity = 6;
656670
// Additional details to be stored as last activity heartbeat
657671
temporal.api.common.v1.Payloads last_heartbeat_details = 7;
672+
// Resource ID for routing. Contains "workflow:workflow_id" or "activity:activity_id" for standalone activities.
673+
string resource_id = 8;
658674
}
659675

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

708728
message RespondActivityTaskCanceledByIdResponse {
@@ -1916,6 +1936,9 @@ message ExecuteMultiOperationRequest {
19161936
// Note that additional operation-specific restrictions have to be considered.
19171937
repeated Operation operations = 2;
19181938

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

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

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

26412669
message FetchWorkerConfigResponse {
@@ -2662,6 +2690,8 @@ message UpdateWorkerConfigRequest {
26622690

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

26672697
message UpdateWorkerConfigResponse {

0 commit comments

Comments
 (0)