@@ -138,6 +138,25 @@ class CancelWorkflowRunOptions:
138138 """The ID of the workflow to cancel."""
139139
140140
141+ @dataclass (frozen = True )
142+ class CancelUpdateWorkflowOptions :
143+ """Options for cancelling the workflow update backing a Nexus operation.
144+
145+ These options are built by :py:class:`TemporalOperationHandler` and passed to
146+ :py:meth:`TemporalOperationHandler.cancel_workflow_update`.
147+
148+ .. warning::
149+ This API is experimental and unstable.
150+ """
151+
152+ workflow_id : str
153+ """The ID of the workflow where the update is running."""
154+ update_id : str
155+ """The ID of the update to cancel."""
156+ run_id : str
157+ """The workflow runID that accepted the update"""
158+
159+
141160class TemporalOperationHandler (OperationHandler [InputT , OutputT ], ABC ):
142161 """Operation handler for Nexus operations that interact with Temporal.
143162 Implementations override the start_operation method.
@@ -190,6 +209,15 @@ async def cancel(self, ctx: CancelOperationContext, token: str) -> None:
190209 workflow_id = operation_token .workflow_id
191210 )
192211 await self .cancel_workflow_run (cancel_ctx , options )
212+ case OperationTokenType .UPDATE_WORKFLOW :
213+ assert operation_token .update_id is not None
214+ assert operation_token .run_id is not None
215+ cancel_options = CancelUpdateWorkflowOptions (
216+ workflow_id = operation_token .workflow_id ,
217+ update_id = operation_token .update_id ,
218+ run_id = operation_token .run_id ,
219+ )
220+ await self .cancel_workflow_update (cancel_ctx , cancel_options )
193221
194222 async def cancel_workflow_run (
195223 self ,
@@ -205,3 +233,23 @@ async def cancel_workflow_run(
205233 options .workflow_id
206234 )
207235 await workflow_handle .cancel ()
236+
237+ # draft-review: maybe just move it inline, no need for a function just to error out
238+ # check after review in case theres some other way to override/supply custom cancels
239+ async def cancel_workflow_update (
240+ self ,
241+ ctx : TemporalCancelOperationContext , # pyright: ignore[reportUnusedParameter]
242+ options : CancelUpdateWorkflowOptions , # pyright: ignore[reportUnusedParameter]
243+ ) -> None :
244+ """Cancels the workflow update backing the Nexus operation.
245+
246+ .. warning::
247+ This API is experimental and unstable.
248+ """
249+ raise HandlerError (
250+ """
251+ Cancellation is not natively supported for update-workflow Nexus operations.
252+ Override a TemporalOperationHandler and implement this method to run cancellable workflow updates.
253+ """ ,
254+ type = HandlerErrorType .NOT_IMPLEMENTED ,
255+ )
0 commit comments