@@ -138,6 +138,23 @@ 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+
157+
141158class TemporalOperationHandler (OperationHandler [InputT , OutputT ], ABC ):
142159 """Operation handler for Nexus operations that interact with Temporal.
143160 Implementations override the start_operation method.
@@ -190,6 +207,13 @@ async def cancel(self, ctx: CancelOperationContext, token: str) -> None:
190207 workflow_id = operation_token .workflow_id
191208 )
192209 await self .cancel_workflow_run (cancel_ctx , options )
210+ case OperationTokenType .UPDATE_WORKFLOW :
211+ assert operation_token .update_id is not None
212+ options = CancelUpdateWorkflowOptions (
213+ workflow_id = operation_token .workflow_id ,
214+ update_id = operation_token .update_id ,
215+ )
216+ await self .cancel_workflow_update (cancel_ctx , options )
193217
194218 async def cancel_workflow_run (
195219 self ,
@@ -205,3 +229,23 @@ async def cancel_workflow_run(
205229 options .workflow_id
206230 )
207231 await workflow_handle .cancel ()
232+
233+ # draft-review: maybe just move it inline, no need for a function just to error out
234+ # check after review in case theres some other way to override/supply custom cancels
235+ async def cancel_workflow_update (
236+ self ,
237+ ctx : TemporalCancelOperationContext , # pyright: ignore[reportUnusedParameter]
238+ options : CancelUpdateWorkflowOptions , # pyright: ignore[reportUnusedParameter]
239+ ) -> None :
240+ """Cancels the workflow update backing the Nexus operation.
241+
242+ .. warning::
243+ This API is experimental and unstable.
244+ """
245+ raise HandlerError (
246+ """
247+ Cancellation is not natively supported for update-workflow Nexus operations.
248+ Override a TemporalOperationHandler and implement this method to run cancellable workflow updates.
249+ """ ,
250+ type = HandlerErrorType .NOT_IMPLEMENTED ,
251+ )
0 commit comments