Skip to content

Add activity cancels from nexus#1160

Merged
Sushisource merged 13 commits into
mainfrom
add-activity-cancels-from-nexus
May 27, 2026
Merged

Add activity cancels from nexus#1160
Sushisource merged 13 commits into
mainfrom
add-activity-cancels-from-nexus

Conversation

@Sushisource
Copy link
Copy Markdown
Member

@Sushisource Sushisource commented Mar 17, 2026

Creates a worker which polls on the appropriately-named worker commands nexus task queue, and handles and activity cancellations sent down it.

The worker is not started unless the server supports this capability.

Comment thread crates/sdk-core/src/worker/heartbeat.rs Outdated
Comment thread crates/common/src/protos/mod.rs Outdated
}
}
}
pub mod nexusservices {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Does the nexus worker send heartbeat? If it does, then I need to find a way to exclude this from the ListWorkers result.

Copy link
Copy Markdown
Member Author

@Sushisource Sushisource May 11, 2026

Choose a reason for hiding this comment

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

~Good question. It shouldn't, if it does I'll make sure it doesn't. ~

Changed my mind. We are already making sure it gets excluded from metrics (since we saw it show up and had that whole discussion re: Nexus usage), and being able to diagnose possible issues with it (getting overloaded, not enough slots, whatever) is useful. Also being dealt with here: temporalio/cli#1019

@Sushisource Sushisource force-pushed the add-activity-cancels-from-nexus branch 2 times, most recently from 322f2a4 to 4f0e626 Compare May 11, 2026 22:08
@Sushisource Sushisource marked this pull request as ready for review May 11, 2026 22:08
@Sushisource Sushisource requested a review from a team as a code owner May 11, 2026 22:09
@Sushisource Sushisource force-pushed the add-activity-cancels-from-nexus branch from 4f0e626 to 8bc16e3 Compare May 11, 2026 22:32
@Sushisource Sushisource force-pushed the add-activity-cancels-from-nexus branch 4 times, most recently from 1cfd5f0 to 6379fe0 Compare May 27, 2026 00:37
@Sushisource Sushisource enabled auto-merge (squash) May 27, 2026 15:46
@Sushisource Sushisource force-pushed the add-activity-cancels-from-nexus branch from cf86496 to 7d0d454 Compare May 27, 2026 17:07
Copy link
Copy Markdown
Contributor

@yuandrew yuandrew left a comment

Choose a reason for hiding this comment

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

A few minor things, biggest question is should we update any public/user facing docstrings to mention activity cancellation can now be delivered without activity heartbeats when worker heartbeating is enabled?

.build(),
);
// Timer needed to avoid cancel-before-sent
ctx.timer(Duration::from_millis(10)).await;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This doesn't actually guarantee the activity has started, right? Only that it's been scheduled? Can we better guarantee that the activity has started?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It doesn't but that doesn't matter, it only needs to be scheduled here

.unwrap()
.into_inner();
#[allow(deprecated)]
#[allow(deprecated)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

?

Copy link
Copy Markdown
Member Author

@Sushisource Sushisource May 27, 2026

Choose a reason for hiding this comment

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

Lol what. Thanks. I think it was a merge issue.

identity: self.identity(),
worker_version_capabilities: self.worker_version_capabilities(),
deployment_options: self.deployment_options(),
// TODO: Piggyback worker heartbeats here if this is the system nexus worker and reset
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We have something tracking this work? Worried this will get lost. If not, i can make one and assign it to myself, I'll need to dig up my old impl for this, I remember doing this like a year ago haha

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We should as part of the overall workstream - but yes please make sure we are somewhere

);
// Timer needed to avoid cancel-before-sent
ctx.timer(Duration::from_millis(10)).await;
act_fut.cancel();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It never clicked from me until now that this is all it takes to cancel the activity. Some reason I thought there would need to be special actions you'd have to initiate from the server, or something. Very nice

@Sushisource
Copy link
Copy Markdown
Member Author

A few minor things, biggest question is should we update any public/user facing docstrings to mention activity cancellation can now be delivered without activity heartbeats when worker heartbeating is enabled?

We certainly will in lang layers but, I don't think there's actually much in core that will need to change. I'll look for any and change them if so (Rust SDK itself perhaps, but, I'm not sure it ever mentioned this limitation anywhere).

@Sushisource Sushisource merged commit a3660f4 into main May 27, 2026
22 of 23 checks passed
@Sushisource Sushisource deleted the add-activity-cancels-from-nexus branch May 27, 2026 19:42
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