Skip to content

Commit acc5707

Browse files
authored
Add process key, make heartbeats repeatable field (#608)
<!-- Describe what has changed in this PR --> **What changed?** Add "process_key" to the worker host info. Make "worker_heartbeat" repeatable in "PollNexus" and "RecordHeartbeat" APIs. <!-- Tell your future self why have you made these changes --> **Why?** We decide to have a single Q per process. Thus we need a way to agree on task queue name, and for that we need this information to be: * available as a part of heartbeat * unique across at least namespace Process ID is not unique. Since we send all heartbeats at once - we make them repeated. <!-- Are there any breaking changes on binary or code level? --> **Breaking changes** Not yet.
1 parent f73d351 commit acc5707

File tree

5 files changed

+38
-10
lines changed

5 files changed

+38
-10
lines changed

buf.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ breaking:
1313
- WIRE_JSON
1414
ignore:
1515
- google
16-
# TODO (yuri) remove this
17-
- temporal/api/workflow/v1/message.proto
16+
# TODO (yuri) remove this. Added for "heartbeat" change (add
17+
- temporal/api/workflowservice/v1/request_response.proto
1818
lint:
1919
use:
2020
- DEFAULT

openapi/openapiv2.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7606,7 +7606,11 @@
76067606
"description": "The identity of the client who initiated this request."
76077607
},
76087608
"workerHeartbeat": {
7609-
"$ref": "#/definitions/v1WorkerHeartbeat"
7609+
"type": "array",
7610+
"items": {
7611+
"type": "object",
7612+
"$ref": "#/definitions/v1WorkerHeartbeat"
7613+
}
76107614
}
76117615
}
76127616
},
@@ -15410,9 +15414,13 @@
1541015414
"type": "string",
1541115415
"description": "Worker host identifier."
1541215416
},
15417+
"processKey": {
15418+
"type": "string",
15419+
"title": "Worker process identifier. This id should be unique for all _processes_\nrunning workers in the namespace, and should be shared by all workers\nin the same process.\nThis will be used to build the worker command nexus task queue name:\n\"temporal-sys/worker-commands/{process_key}\""
15420+
},
1541315421
"processId": {
1541415422
"type": "string",
15415-
"description": "Worker process identifier, should be unique for the host."
15423+
"description": "Worker process identifier. Unlike process_key, this id only needs to be unique\nwithin one host (so using e.g. a unix pid would be appropriate)."
1541615424
},
1541715425
"currentHostCpuUsage": {
1541815426
"type": "number",

openapi/openapiv3.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9723,7 +9723,9 @@ components:
97239723
type: string
97249724
description: The identity of the client who initiated this request.
97259725
workerHeartbeat:
9726-
$ref: '#/components/schemas/WorkerHeartbeat'
9726+
type: array
9727+
items:
9728+
$ref: '#/components/schemas/WorkerHeartbeat'
97279729
RecordWorkerHeartbeatResponse:
97289730
type: object
97299731
properties: {}
@@ -12797,9 +12799,19 @@ components:
1279712799
hostName:
1279812800
type: string
1279912801
description: Worker host identifier.
12802+
processKey:
12803+
type: string
12804+
description: |-
12805+
Worker process identifier. This id should be unique for all _processes_
12806+
running workers in the namespace, and should be shared by all workers
12807+
in the same process.
12808+
This will be used to build the worker command nexus task queue name:
12809+
"temporal-sys/worker-commands/{process_key}"
1280012810
processId:
1280112811
type: string
12802-
description: Worker process identifier, should be unique for the host.
12812+
description: |-
12813+
Worker process identifier. Unlike process_key, this id only needs to be unique
12814+
within one host (so using e.g. a unix pid would be appropriate).
1280312815
currentHostCpuUsage:
1280412816
type: number
1280512817
description: |-

temporal/api/worker/v1/message.proto

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,16 @@ message WorkerHostInfo {
5454
// Worker host identifier.
5555
string host_name = 1;
5656

57-
// Worker process identifier, should be unique for the host.
57+
58+
// Worker process identifier. This id should be unique for all _processes_
59+
// running workers in the namespace, and should be shared by all workers
60+
// in the same process.
61+
// This will be used to build the worker command nexus task queue name:
62+
// "temporal-sys/worker-commands/{process_key}"
63+
string process_key = 5;
64+
65+
// Worker process identifier. Unlike process_key, this id only needs to be unique
66+
// within one host (so using e.g. a unix pid would be appropriate).
5867
string process_id = 2;
5968

6069
// System used CPU as a float in the range [0.0, 1.0] where 1.0 is defined as all
@@ -78,7 +87,6 @@ message WorkerHeartbeat {
7887
// Usually host_name+(user group name)+process_id, but can be overwritten by the user.
7988
string worker_identity = 2;
8089

81-
8290
// Worker host information.
8391
WorkerHostInfo host_info = 3;
8492

temporal/api/workflowservice/v1/request_response.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,7 @@ message PollNexusTaskQueueRequest {
17721772
temporal.api.deployment.v1.WorkerDeploymentOptions deployment_options = 6;
17731773

17741774
// Worker info to be sent to the server.
1775-
temporal.api.worker.v1.WorkerHeartbeat worker_heartbeat = 7;
1775+
repeated temporal.api.worker.v1.WorkerHeartbeat worker_heartbeat = 7;
17761776
}
17771777

17781778
message PollNexusTaskQueueResponse {
@@ -2384,7 +2384,7 @@ message RecordWorkerHeartbeatRequest {
23842384
// The identity of the client who initiated this request.
23852385
string identity = 2;
23862386

2387-
temporal.api.worker.v1.WorkerHeartbeat worker_heartbeat = 3;
2387+
repeated temporal.api.worker.v1.WorkerHeartbeat worker_heartbeat = 3;
23882388
}
23892389

23902390
message RecordWorkerHeartbeatResponse {

0 commit comments

Comments
 (0)