Skip to content

Add Nexus request and response payloads to cancel activities#708

Draft
rkannan82 wants to merge 2 commits intomasterfrom
kannan/activity-cancel
Draft

Add Nexus request and response payloads to cancel activities#708
rkannan82 wants to merge 2 commits intomasterfrom
kannan/activity-cancel

Conversation

@rkannan82
Copy link

@rkannan82 rkannan82 commented Feb 3, 2026

Added Nexus request and response protos for canceling workflow activities.

This is the first use case for sending commands to worker using Nexus queue. It allows us to cancel in-flight activities when a user cancels the workflow (even when activity heartbeat is not enabled).

@rkannan82 rkannan82 requested review from a team as code owners February 3, 2026 21:30
@rkannan82 rkannan82 force-pushed the kannan/activity-cancel branch 3 times, most recently from 4b2e0d1 to 54edb8e Compare February 3, 2026 21:42
Comment on lines 144 to 168
// 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;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arguably we shouldn't have to use proto for this, but even if we do, can these be defined at the same time as the exact Nexus service?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, what did you mean by "define at the same time as Nexus service"? I have now documented the nexus service and command name.

}

// Container for batching multiple control tasks delivered to a worker in one Nexus operation.
message WorkerControlTasks {
Copy link
Member

@cretz cretz Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is meant to be the Nexus input/request, it should be named as such and you need a output/response of an operation (even if it is empty at first). You should also define even what the service name and operation are expected to be. Having an input model only with no output model, no service name, and no operation name makes me concerned this isn't fully designed yet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a new file, as it's defining a new nexus service, not the typical grpc service, see the previous discussion here, #622 (comment),
specifically what spencer said

For now I would suggest moving these commands into another proto file inside worker/v1 like worker_nexus_service_commands.proto and a big block comment at the top can say the service name, and the operation names, and how they correspond to workflowservice rpcs

I think we were all on board with Yuri's design of worker_nexus_service_commands.proto, and we should do something similar here where the new file contains the block comment giving more information about the new nexus service

// (--
/////////////////////////////////////////////////////////////////////
// This file contains:
// - Conventions between server and worker.
// - Definitions for commands and payloads for server-worker communication via Nexus
... and so on

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take another look. I have incorporated Yuris' PR style in here.

}

// Container for batching multiple control tasks delivered to a worker in one Nexus operation.
message WorkerControlTasks {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO input to the worker Nexus service should provide the worker instance key the control call is targeting. This is a shared Nexus worker.

On a side note, I think we will want to implement a form of this end-to-end before we merge what we think the models needed will be.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree that we should have something in server and SDK working (in branches) with this definition before we merge

Add WorkerControlTasks, WorkerControlTask, and CancelActivityTask to worker/v1/message.proto
for pushing control messages to workers via Nexus control queue.
@rkannan82 rkannan82 force-pushed the kannan/activity-cancel branch 2 times, most recently from afb40a2 to b920471 Compare February 4, 2026 05:43
@rkannan82 rkannan82 changed the title Add API to send control tasks from server to worker Add Nexus request and response payloads to cancel activities Feb 4, 2026
@rkannan82 rkannan82 requested a review from cretz February 4, 2026 05:50
- 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
@rkannan82 rkannan82 force-pushed the kannan/activity-cancel branch from b920471 to 84c0bac Compare February 4, 2026 05:51
@rkannan82 rkannan82 marked this pull request as draft February 4, 2026 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants