From 3fcab461e5b5574ef83cb747699ad7104da73528 Mon Sep 17 00:00:00 2001 From: Kannan Rajah Date: Wed, 14 Jan 2026 13:57:49 -0800 Subject: [PATCH 1/2] Add worker control task protos for activity cancellation Add WorkerControlTasks, WorkerControlTask, and CancelActivityTask to worker/v1/message.proto for pushing control messages to workers via Nexus control queue. --- temporal/api/worker/v1/message.proto | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/temporal/api/worker/v1/message.proto b/temporal/api/worker/v1/message.proto index 3df3aaa33..ec39722c0 100644 --- a/temporal/api/worker/v1/message.proto +++ b/temporal/api/worker/v1/message.proto @@ -11,6 +11,7 @@ option csharp_namespace = "Temporalio.Api.Worker.V1"; import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; +import "temporal/api/common/v1/message.proto"; import "temporal/api/deployment/v1/message.proto"; import "temporal/api/enums/v1/common.proto"; @@ -139,3 +140,29 @@ message PluginInfo { // The version of the plugin, may be empty. string version = 2; } + +// Container for batching multiple control tasks delivered to a worker in one Nexus operation. +message WorkerControlTasks { + repeated WorkerControlTask tasks = 1; +} + +// A single control task for a worker. +message WorkerControlTask { + // Timestamp when this task was created. + google.protobuf.Timestamp create_time = 1; + + oneof task { + CancelActivityTask cancel_activity = 2; + } +} + +// Request to cancel running activities on this worker. +message CancelActivityTask { + // The workflow execution that owns the activities. + temporal.api.common.v1.WorkflowExecution workflow_execution = 1; + // The scheduled event IDs of activities to cancel. + // If empty, cancel all activities for this workflow running on this worker. + repeated int64 scheduled_event_ids = 2; + // Human-readable reason for cancellation. + string reason = 3; +} From 84c0bac089283171737d176763497e2c574c64e8 Mon Sep 17 00:00:00 2001 From: Kannan Rajah Date: Tue, 3 Feb 2026 20:25:03 -0800 Subject: [PATCH 2/2] Refactor worker control protos: separate file and use task tokens - Move Nexus command payloads to worker_nexus_service_commands.proto - Rename to CancelActivitiesRequestPayload/ResponsePayload - Use task_tokens instead of workflow_execution + scheduled_event_ids - Add file-level documentation for Nexus conventions --- temporal/api/worker/v1/message.proto | 27 ---------- .../v1/worker_nexus_service_commands.proto | 49 +++++++++++++++++++ 2 files changed, 49 insertions(+), 27 deletions(-) create mode 100644 temporal/api/worker/v1/worker_nexus_service_commands.proto diff --git a/temporal/api/worker/v1/message.proto b/temporal/api/worker/v1/message.proto index ec39722c0..3df3aaa33 100644 --- a/temporal/api/worker/v1/message.proto +++ b/temporal/api/worker/v1/message.proto @@ -11,7 +11,6 @@ option csharp_namespace = "Temporalio.Api.Worker.V1"; import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; -import "temporal/api/common/v1/message.proto"; import "temporal/api/deployment/v1/message.proto"; import "temporal/api/enums/v1/common.proto"; @@ -140,29 +139,3 @@ message PluginInfo { // The version of the plugin, may be empty. string version = 2; } - -// Container for batching multiple control tasks delivered to a worker in one Nexus operation. -message WorkerControlTasks { - repeated WorkerControlTask tasks = 1; -} - -// A single control task for a worker. -message WorkerControlTask { - // Timestamp when this task was created. - google.protobuf.Timestamp create_time = 1; - - oneof task { - CancelActivityTask cancel_activity = 2; - } -} - -// Request to cancel running activities on this worker. -message CancelActivityTask { - // The workflow execution that owns the activities. - temporal.api.common.v1.WorkflowExecution workflow_execution = 1; - // The scheduled event IDs of activities to cancel. - // If empty, cancel all activities for this workflow running on this worker. - repeated int64 scheduled_event_ids = 2; - // Human-readable reason for cancellation. - string reason = 3; -} diff --git a/temporal/api/worker/v1/worker_nexus_service_commands.proto b/temporal/api/worker/v1/worker_nexus_service_commands.proto new file mode 100644 index 000000000..d4903d504 --- /dev/null +++ b/temporal/api/worker/v1/worker_nexus_service_commands.proto @@ -0,0 +1,49 @@ +syntax = "proto3"; + +package temporal.api.worker.v1; + +option go_package = "go.temporal.io/api/worker/v1;worker"; +option java_package = "io.temporal.api.worker.v1"; +option java_multiple_files = true; +option java_outer_classname = "WorkerNexusServiceCommandsProto"; +option ruby_package = "Temporalio::Api::Worker::V1"; +option csharp_namespace = "Temporalio.Api.Worker.V1"; + +// (-- +///////////////////////////////////////////////////////////////////// +// This file contains: +// - Conventions between server and worker. +// - Definitions for commands and payloads for server-worker communication via Nexus +// +// COMMUNICATION PROTOCOL: +// - Transport: Nexus tasks on task queue +// - Server identifier: "sys-worker-service" +// - Task queue: /temporal-sys/worker-commands/{namespace}/{worker_grouping_key} +// +// WORKER COMMANDS CONVENTIONS: +// +// - Worker commands are used to manage worker configurations, operations, etc. +// - Command names should match names defined in the server API. +// - Command names are provided in StartOperationRequest.Operation field. +// +// PAYLOAD CONVENTIONS: +// +// - In/out payloads namings follow the same convention as the regular API: +// - CommandNameRequest (input payload) +// - CommandNameResponse (output payload). +// - Empty payload if response is not needed/not expected +// +// --) + +// Request payload for the "cancel-activities" Nexus operation. +message CancelActivitiesRequestPayload { + // Task tokens identifying the activities to cancel. + // Each token corresponds to a specific activity task that the worker received. + repeated bytes task_tokens = 1; +} + +// Response payload for the "cancel-activities" Nexus operation. +message CancelActivitiesResponsePayload { + // Empty for now. Can be extended to include cancellation status per activity. +} +