Add NexusOperationHandler annotation - #764
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f76d3e21a7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
jmaeagle99
left a comment
There was a problem hiding this comment.
Small amount of feedback, but looks good overall. Will approve when dependency has been updated.
Side note: this is ripe for source generation, which would create compile-time safe operation registration, but still use the reflection and expression compilation as a fallback. I'm going to log an issue to track this, as there are other areas that can benefit as well.
|
Please update CHANGELOG.md with a blurb in the Added section. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 1f2f3e3. Configure here.
f347b9a to
24200f6
Compare
jmaeagle99
left a comment
There was a problem hiding this comment.
I think the one pitfall of this design is that if a method is attributed with [TemporalOperation] but it's name doesn't match a method in the service interface, then it is silently ignored. This might lead to typo-created mismatches given that the service implementation doesn't implemented the service interface. Not sure what to do with that without given the entire service definition to Temporalio to validate all attributed methods at once. Maybe could be done better with an analyzer.

What was changed
Add
NexusOperationHandlerannotation that can be used in Nexus Service Handlers on Temporal WorkersWhy?
Makes it easier to declare Nexus Service Handlers with less boilerplate
Checklist
Closes
How was this tested:
Note to reviewers:
nexus-rpc/sdk-dotnet#19 needs to land first and most of the package lock changes are only here to test locally
Note
Medium Risk
Touches experimental Nexus operation registration, reflection/expression binding, and hosting DI scoping; build currently depends on a local NexusRpc project reference until the companion SDK change ships.
Overview
Adds
[TemporalOperation]so a method on a[NexusServiceHandler]class can be the Nexus operation start handler directly (signatureTask<TemporalOperationResult<T>>withTemporalOperationStartContextandITemporalNexusClient), instead of returning anIOperationHandlerfrom a[NexusOperationHandler]factory. Registration wires this through a newTemporalOperationMethodExtension(IMethodExtension) that validates signatures and buildsTemporalOperationHandlervia compiled delegates;AddNexusServiceon workers and simple plugins now passes that extension intoServiceHandlerInstance.FromInstance.Hosting is refactored so
ServiceHandlerInstanceHelperdiscovers operations by method name and delegates to a factory that supports both attribute styles.[TemporalOperation]handlers get per start/cancel DI scopes (like activities), reusing the same validation/factory internals viaInternalsVisibleTo. Unmatched[NexusOperationHandler]methods fail registration consistently with NexusRpc.Temporaliotemporarily references the local NexusRpc project (instead of the NuGet package) to pick up extension APIs pending the upstream Nexus SDK PR; lockfiles reflect that. Changelog and broad integration tests cover workflow starts, sync results, void/no-input ops, mixed handlers on one service, and registration errors.Reviewed by Cursor Bugbot for commit 24200f6. Bugbot is set up for automated code reviews on this repo. Configure here.