From ec8bdd5abbd7039a26bd67ca463c66d4b4146064 Mon Sep 17 00:00:00 2001 From: Shivam Saraf Date: Tue, 24 Nov 2026 11:36:41 -0500 Subject: [PATCH] Carry a worker's session options on its heartbeat --- openapi/openapiv2.json | 38 +++++++++++++++++++ openapi/openapiv3.yaml | 57 ++++++++++++++++++++++++++++ temporal/api/worker/v1/message.proto | 5 +++ 3 files changed, 100 insertions(+) diff --git a/openapi/openapiv2.json b/openapi/openapiv2.json index 59608b893..2347e0331 100644 --- a/openapi/openapiv2.json +++ b/openapi/openapiv2.json @@ -17372,6 +17372,16 @@ }, "title": "Metadata relevant for metering purposes" }, + "v1MultiSessionOptions": { + "type": "object", + "properties": { + "workerAddress": { + "type": "string", + "description": "Where the server routes session work bound to this worker.\nCurrently set by the SDK to the worker's sticky queue name, and not\nuser-configurable. May become configurable in the future." + } + }, + "description": "EXPERIMENTAL. Subject to redesign or removal.\nServe any number of sessions concurrently. Future admission knobs (e.g.\nsession slots) belong here." + }, "v1NamespaceConfig": { "type": "object", "properties": { @@ -20140,6 +20150,16 @@ } } }, + "v1SingleSessionOptions": { + "type": "object", + "properties": { + "stableIdentity": { + "type": "string", + "description": "Identity the binding is stored under. Required; must be non-empty.\nReuse it across restarts of the same session, not across concurrently\nrunning workers. If multiple workers poll with the same stable_identity\nconcurrently, the server treats them as pollers of a single worker and\nprocess affinity is lost.\n\nNote: this effectively acts as a configurable sticky queue.\nNote: we are currently unsure how this will evolve. May be deprecated as\nthe session model develops." + } + }, + "description": "EXPERIMENTAL. Subject to redesign or removal.\nServe exactly one session for the worker's lifetime, including across\nprocess restarts with the same stable_identity. The server binds the worker\nto the first session that needs a worker, and dispatches no other work here,\neven after that session completes." + }, "v1StartActivityExecutionResponse": { "type": "object", "properties": { @@ -21543,6 +21563,10 @@ "environment": { "$ref": "#/definitions/v1EnvironmentInfo", "description": "Information about the environment this SDK is running in." + }, + "sessionOptions": { + "$ref": "#/definitions/v1WorkerSessionOptions", + "description": "The worker's session options, as sent on its polls. Lets the server recognize a multi-session worker that has\nstopped, so it can move the workflows bound to it to other workers. Unset for a worker without sessions." } }, "description": "Worker info message, contains information about the worker and its current state.\nAll information is provided by the worker itself." @@ -21681,6 +21705,20 @@ }, "description": "This is used to send commands to a specific worker or a group of workers.\nRight now, it is used to send commands to a specific worker instance.\nWill be extended to be able to send command to multiple workers." }, + "v1WorkerSessionOptions": { + "type": "object", + "properties": { + "singleSession": { + "$ref": "#/definitions/v1SingleSessionOptions", + "description": "If specified, the worker only polls for work belonging to its session." + }, + "multiSession": { + "$ref": "#/definitions/v1MultiSessionOptions", + "description": "If specified, the worker can serve multiple sessions at once." + } + }, + "description": "EXPERIMENTAL. Subject to redesign or removal.\nSent on workflow and activity polls. Presence means this worker can serve\nsessions. Currently, the only supported Session type is Workflow Session\n(aka Workflow-as-Session). A Workflow Session can receive both workflow\ntasks and activity tasks of an execution." + }, "v1WorkerSlotsInfo": { "type": "object", "properties": { diff --git a/openapi/openapiv3.yaml b/openapi/openapiv3.yaml index c7beb4f98..422711ea7 100644 --- a/openapi/openapiv3.yaml +++ b/openapi/openapiv3.yaml @@ -13601,6 +13601,19 @@ components: aip.dev/not-precedent: Negative values make no sense to represent. --) format: uint32 description: Metadata relevant for metering purposes + MultiSessionOptions: + type: object + properties: + workerAddress: + type: string + description: |- + Where the server routes session work bound to this worker. + Currently set by the SDK to the worker's sticky queue name, and not + user-configurable. May become configurable in the future. + description: |- + EXPERIMENTAL. Subject to redesign or removal. + Serve any number of sessions concurrently. Future admission knobs (e.g. + session slots) belong here. NamespaceConfig: type: object properties: @@ -17328,6 +17341,27 @@ components: Link to be associated with the WorkflowExecutionSignaled event. Added on the response to propagate the backlink. Available from Temporal server 1.31 and up. + SingleSessionOptions: + type: object + properties: + stableIdentity: + type: string + description: |- + Identity the binding is stored under. Required; must be non-empty. + Reuse it across restarts of the same session, not across concurrently + running workers. If multiple workers poll with the same stable_identity + concurrently, the server treats them as pollers of a single worker and + process affinity is lost. + + Note: this effectively acts as a configurable sticky queue. + Note: we are currently unsure how this will evolve. May be deprecated as + the session model develops. + description: |- + EXPERIMENTAL. Subject to redesign or removal. + Serve exactly one session for the worker's lifetime, including across + process restarts with the same stable_identity. The server binds the worker + to the first session that needs a worker, and dispatches no other work here, + even after that session completes. StartActivityExecutionRequest: type: object properties: @@ -19982,6 +20016,12 @@ components: allOf: - $ref: '#/components/schemas/EnvironmentInfo' description: Information about the environment this SDK is running in. + sessionOptions: + allOf: + - $ref: '#/components/schemas/WorkerSessionOptions' + description: |- + The worker's session options, as sent on its polls. Lets the server recognize a multi-session worker that has + stopped, so it can move the workflows bound to it to other workers. Unset for a worker without sessions. description: |- Worker info message, contains information about the worker and its current state. All information is provided by the worker itself. @@ -20116,6 +20156,23 @@ components: This is used to send commands to a specific worker or a group of workers. Right now, it is used to send commands to a specific worker instance. Will be extended to be able to send command to multiple workers. + WorkerSessionOptions: + type: object + properties: + singleSession: + allOf: + - $ref: '#/components/schemas/SingleSessionOptions' + description: If specified, the worker only polls for work belonging to its session. + multiSession: + allOf: + - $ref: '#/components/schemas/MultiSessionOptions' + description: If specified, the worker can serve multiple sessions at once. + description: |- + EXPERIMENTAL. Subject to redesign or removal. + Sent on workflow and activity polls. Presence means this worker can serve + sessions. Currently, the only supported Session type is Workflow Session + (aka Workflow-as-Session). A Workflow Session can receive both workflow + tasks and activity tasks of an execution. WorkerSlotsInfo: type: object properties: diff --git a/temporal/api/worker/v1/message.proto b/temporal/api/worker/v1/message.proto index cc452f0c2..f8a88db63 100644 --- a/temporal/api/worker/v1/message.proto +++ b/temporal/api/worker/v1/message.proto @@ -13,6 +13,7 @@ import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; import "temporal/api/deployment/v1/message.proto"; import "temporal/api/enums/v1/common.proto"; +import "temporal/api/session/v1/message.proto"; message WorkerPollerInfo { // Number of polling RPCs that are currently in flight. @@ -137,6 +138,10 @@ message WorkerHeartbeat { // Information about the environment this SDK is running in. EnvironmentInfo environment = 25; + + // The worker's session options, as sent on its polls. Lets the server recognize a multi-session worker that has + // stopped, so it can move the workflows bound to it to other workers. Unset for a worker without sessions. + temporal.api.session.v1.WorkerSessionOptions session_options = 26; } // Detailed worker information.