5656# TODO(dan): confirm approach here: Temporal Nexus services will use this instead of
5757# nexusrpc.handler.Operation in order to avoid having to implement fetch_info and
5858# fetch_result.
59- class Operation (nexusrpc .OperationHandler [I , O ]):
59+ class Operation (nexusrpc .handler . OperationHandler [I , O ]):
6060 """
6161 Interface that must be implemented by an operation in a Temporal Nexus service.
6262 """
6363
6464 # fetch_info and fetch_result are not currently to be implemented by Temporal Nexus services.
6565
6666 async def fetch_info (
67- self , token : str , ctx : nexusrpc .FetchOperationInfoContext
68- ) -> nexusrpc .OperationInfo :
67+ self , token : str , ctx : nexusrpc .handler . FetchOperationInfoContext
68+ ) -> nexusrpc .handler . OperationInfo :
6969 raise NotImplementedError
7070
7171 async def fetch_result (
72- self , token : str , ctx : nexusrpc .FetchOperationResultContext
72+ self , token : str , ctx : nexusrpc .handler . FetchOperationResultContext
7373 ) -> O :
7474 raise NotImplementedError
7575
7676
7777# TODO(dan): naming, visibility, make this less awkward
7878def get_input_and_output_types_from_workflow_run_start_method (
7979 start_method : Callable [
80- [S , nexusrpc .StartOperationContext , I ],
80+ [S , nexusrpc .handler . StartOperationContext , I ],
8181 Awaitable [WorkflowHandle [Any , O ]],
8282 ],
8383) -> tuple [
@@ -120,7 +120,7 @@ def get_input_and_output_types_from_workflow_run_start_method(
120120# No-param overload
121121@overload
122122async def start_workflow (
123- ctx : nexusrpc .StartOperationContext ,
123+ ctx : nexusrpc .handler . StartOperationContext ,
124124 workflow : MethodAsyncNoParam [SelfType , ReturnType ],
125125 * ,
126126 id : str ,
@@ -132,7 +132,7 @@ async def start_workflow(
132132# Single-param overload
133133@overload
134134async def start_workflow (
135- ctx : nexusrpc .StartOperationContext ,
135+ ctx : nexusrpc .handler . StartOperationContext ,
136136 workflow : MethodAsyncSingleParam [SelfType , ParamType , ReturnType ],
137137 arg : ParamType ,
138138 * ,
@@ -145,7 +145,7 @@ async def start_workflow(
145145# Multiple-params overload
146146@overload
147147async def start_workflow (
148- ctx : nexusrpc .StartOperationContext ,
148+ ctx : nexusrpc .handler . StartOperationContext ,
149149 workflow : Callable [Concatenate [SelfType , MultiParamSpec ], Awaitable [ReturnType ]],
150150 * ,
151151 args : Sequence [Any ],
@@ -159,7 +159,7 @@ async def start_workflow(
159159
160160
161161async def start_workflow (
162- ctx : nexusrpc .StartOperationContext ,
162+ ctx : nexusrpc .handler . StartOperationContext ,
163163 workflow : Callable [..., Awaitable [Any ]],
164164 arg : Any = temporalio .common ._arg_unset ,
165165 * ,
@@ -268,11 +268,11 @@ async def start_workflow(
268268# TODO(dan): Not for merge: this is not required for Temporal Nexus, but implementing in
269269# order to check that the design extends well to this.
270270async def fetch_workflow_info (
271- ctx : nexusrpc .FetchOperationInfoContext ,
271+ ctx : nexusrpc .handler . FetchOperationInfoContext ,
272272 token : str ,
273- ) -> nexusrpc .OperationInfo :
273+ ) -> nexusrpc .handler . OperationInfo :
274274 # TODO(dan)
275- return nexusrpc .OperationInfo (
275+ return nexusrpc .handler . OperationInfo (
276276 token = token ,
277277 status = nexusrpc .handler .OperationState .RUNNING ,
278278 )
@@ -281,7 +281,7 @@ async def fetch_workflow_info(
281281# TODO(dan): Not for merge: this is not required for Temporal Nexus, but implementing temporarily in
282282# order to check that the design extends well to this.
283283async def fetch_workflow_result (
284- ctx : nexusrpc .FetchOperationResultContext ,
284+ ctx : nexusrpc .handler . FetchOperationResultContext ,
285285 token : str ,
286286 client : Optional [Client ] = None ,
287287) -> Any :
@@ -292,7 +292,7 @@ async def fetch_workflow_result(
292292
293293
294294async def cancel_workflow (
295- ctx : nexusrpc .CancelOperationContext ,
295+ ctx : nexusrpc .handler . CancelOperationContext ,
296296 token : str ,
297297 client : Optional [Client ] = None ,
298298) -> None :
@@ -330,12 +330,12 @@ def get_task_queue() -> str:
330330 return context .task_queue
331331
332332
333- class WorkflowRunOperation (nexusrpc .OperationHandler [I , O ], Generic [I , O , S ]):
333+ class WorkflowRunOperation (nexusrpc .handler . OperationHandler [I , O ], Generic [I , O , S ]):
334334 def __init__ (
335335 self ,
336336 service : S ,
337337 start_method : Callable [
338- [S , nexusrpc .StartOperationContext , I ],
338+ [S , nexusrpc .handler . StartOperationContext , I ],
339339 Awaitable [WorkflowHandle [Any , O ]],
340340 ],
341341 output_type : Optional [Type ] = None ,
@@ -346,16 +346,16 @@ def __init__(
346346 # TODO(dan): What is @wraps doing exactly?
347347 @wraps (start_method )
348348 async def start (
349- self , ctx : nexusrpc .StartOperationContext , input : I
350- ) -> nexusrpc .StartOperationResultAsync :
349+ self , ctx : nexusrpc .handler . StartOperationContext , input : I
350+ ) -> nexusrpc .handler . StartOperationResultAsync :
351351 wf_handle = await start_method (service , ctx , input )
352352 token = WorkflowOperationToken .from_workflow_handle (wf_handle ).encode ()
353- return nexusrpc .StartOperationResultAsync (token )
353+ return nexusrpc .handler . StartOperationResultAsync (token )
354354
355355 # TODO(dan): get rid of first parameter?
356356 # TODO(dan): remove before merge; implementing temporarily to check that design extends well to this
357357 async def fetch_result (
358- self , ctx : nexusrpc .FetchOperationResultContext , token : str
358+ self , ctx : nexusrpc .handler . FetchOperationResultContext , token : str
359359 ) -> O :
360360 return await fetch_workflow_result (ctx , token )
361361
@@ -365,13 +365,13 @@ async def fetch_result(
365365 self .start = types .MethodType (start , self )
366366 self .fetch_result = types .MethodType (fetch_result , self )
367367
368- async def cancel (self , ctx : nexusrpc .CancelOperationContext , token : str ) -> None :
368+ async def cancel (self , ctx : nexusrpc .handler . CancelOperationContext , token : str ) -> None :
369369 await cancel_workflow (ctx , token )
370370
371371 # TODO(dan): remove before merge; implementing temporarily to check that design extends well to this
372372 async def fetch_info (
373- self , ctx : nexusrpc .FetchOperationInfoContext , token : str
374- ) -> nexusrpc .OperationInfo :
373+ self , ctx : nexusrpc .handler . FetchOperationInfoContext , token : str
374+ ) -> nexusrpc .handler . OperationInfo :
375375 return await fetch_workflow_info (ctx , token )
376376
377377
@@ -381,7 +381,7 @@ async def fetch_info(
381381def workflow_run_operation (
382382 start_method : Optional [
383383 Callable [
384- [S , nexusrpc .StartOperationContext , I ],
384+ [S , nexusrpc .handler . StartOperationContext , I ],
385385 Awaitable [WorkflowHandle [Any , O ]],
386386 ]
387387 ] = None ,
@@ -392,7 +392,7 @@ def workflow_run_operation(
392392 Callable [
393393 [
394394 Callable [
395- [S , nexusrpc .StartOperationContext , I ],
395+ [S , nexusrpc .handler . StartOperationContext , I ],
396396 Awaitable [WorkflowHandle [Any , O ]],
397397 ]
398398 ],
@@ -401,7 +401,7 @@ def workflow_run_operation(
401401]:
402402 def decorator (
403403 start_method : Callable [
404- [S , nexusrpc .StartOperationContext , I ],
404+ [S , nexusrpc .handler . StartOperationContext , I ],
405405 Awaitable [WorkflowHandle [Any , O ]],
406406 ],
407407 ) -> Callable [[S ], WorkflowRunOperation [I , O , S ]]:
0 commit comments