File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed
Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -228,6 +228,12 @@ def cancel(self, invocation_id: str):
228228 Cancels the invocation with the given id.
229229 """
230230
231+ @abc .abstractmethod
232+ def attach_invocation (self , invocation_id : str , serde : Serde [T ] = JsonSerde ()) -> T :
233+ """
234+ Attaches the invocation with the given id.
235+ """
236+
231237
232238class ObjectContext (Context , KeyValueStore ):
233239 """
Original file line number Diff line number Diff line change @@ -436,3 +436,18 @@ def cancel(self, invocation_id: str):
436436 if invocation_id is None :
437437 raise ValueError ("invocation_id cannot be None" )
438438 self .vm .sys_cancel (invocation_id )
439+
440+ def attach_invocation (self , invocation_id : str , serde : Serde [T ] = JsonSerde ()) -> T :
441+ if invocation_id is None :
442+ raise ValueError ("invocation_id cannot be None" )
443+ assert serde is not None
444+ handle = self .vm .attach_invocation (invocation_id )
445+ coro = self .create_poll_or_cancel_coroutine (handle )
446+
447+ async def await_point ():
448+ """Wait for this handle to be resolved."""
449+ res = await coro
450+ assert res is not None
451+ return serde .deserialize (res )
452+
453+ return await_point ()
Original file line number Diff line number Diff line change @@ -658,6 +658,17 @@ impl PyVM {
658658 . map_err ( Into :: into)
659659 }
660660
661+ fn attach_invocation (
662+ mut self_ : PyRefMut < ' _ , Self > ,
663+ invocation_id : String ,
664+ ) -> Result < PyNotificationHandle , PyVMError > {
665+ self_
666+ . vm
667+ . sys_attach_invocation ( restate_sdk_shared_core:: AttachInvocationTarget :: InvocationId ( invocation_id) )
668+ . map ( Into :: into)
669+ . map_err ( Into :: into)
670+ }
671+
661672 fn sys_end ( mut self_ : PyRefMut < ' _ , Self > ) -> Result < ( ) , PyVMError > {
662673 self_. vm . sys_end ( ) . map ( Into :: into) . map_err ( Into :: into)
663674 }
You can’t perform that action at this time.
0 commit comments