@@ -16,7 +16,8 @@ use futures::{FutureExt, TryFutureExt};
1616use pin_project_lite:: pin_project;
1717use restate_sdk_shared_core:: {
1818 CoreVM , DoProgressResponse , Error as CoreError , Header , NonEmptyValue , NotificationHandle ,
19- RetryPolicy , RunExitResult , TakeOutputResult , Target , TerminalFailure , VM , Value ,
19+ PayloadOptions , RetryPolicy , RunExitResult , TakeOutputResult , Target , TerminalFailure , VM ,
20+ Value ,
2021} ;
2122use std:: borrow:: Cow ;
2223use std:: collections:: HashMap ;
@@ -59,7 +60,7 @@ impl ContextInternalInner {
5960 self . maybe_flip_span_replaying_field ( ) ;
6061 self . vm . notify_error (
6162 CoreError :: new ( 500u16 , e. 0 . to_string ( ) )
62- . with_stacktrace ( Cow :: Owned ( format ! ( "{:#}" , e. 0 ) ) ) ,
63+ . with_stacktrace ( Cow :: < str > :: Owned ( format ! ( "{:#}" , e. 0 ) ) ) ,
6364 None ,
6465 ) ;
6566 self . handler_state . mark_error ( e) ;
@@ -237,7 +238,7 @@ impl ContextInternal {
237238 } ;
238239 let _ = inner_lock
239240 . vm
240- . sys_write_output ( NonEmptyValue :: Failure ( err. into ( ) ) ) ;
241+ . sys_write_output ( NonEmptyValue :: Failure ( err. into ( ) ) , PayloadOptions :: stable ( ) ) ;
241242 let _ = inner_lock. vm . sys_end ( ) ;
242243 // This causes the trap, plus logs the error
243244 inner_lock. handler_state . mark_error ( error_inner. into ( ) ) ;
@@ -256,7 +257,12 @@ impl ContextInternal {
256257 key : & str ,
257258 ) -> impl Future < Output = Result < Option < T > , TerminalError > > + Send {
258259 let mut inner_lock = must_lock ! ( self . inner) ;
259- let handle = unwrap_or_trap ! ( inner_lock, inner_lock. vm. sys_state_get( key. to_owned( ) ) ) ;
260+ let handle = unwrap_or_trap ! (
261+ inner_lock,
262+ inner_lock
263+ . vm
264+ . sys_state_get( key. to_owned( ) , PayloadOptions :: stable( ) )
265+ ) ;
260266 inner_lock. maybe_flip_span_replaying_field ( ) ;
261267
262268 let poll_future = get_async_result ( Arc :: clone ( & self . inner ) , handle) . map ( |res| match res {
@@ -301,7 +307,9 @@ impl ContextInternal {
301307 let mut inner_lock = must_lock ! ( self . inner) ;
302308 match t. serialize ( ) {
303309 Ok ( b) => {
304- let _ = inner_lock. vm . sys_state_set ( key. to_owned ( ) , b) ;
310+ let _ = inner_lock
311+ . vm
312+ . sys_state_set ( key. to_owned ( ) , b, PayloadOptions :: stable ( ) ) ;
305313 inner_lock. maybe_flip_span_replaying_field ( ) ;
306314 }
307315 Err ( e) => {
@@ -391,7 +399,12 @@ impl ContextInternal {
391399 . collect ( ) ;
392400 let call_result = Req :: serialize ( & req)
393401 . map_err ( |e| Error :: serialization ( "call" , e) )
394- . and_then ( |input| inner_lock. vm . sys_call ( target, input) . map_err ( Into :: into) ) ;
402+ . and_then ( |input| {
403+ inner_lock
404+ . vm
405+ . sys_call ( target, input, PayloadOptions :: stable ( ) )
406+ . map_err ( Into :: into)
407+ } ) ;
395408
396409 let call_handle = match call_result {
397410 Ok ( t) => t,
@@ -487,6 +500,7 @@ impl ContextInternal {
487500 . expect ( "Duration since unix epoch cannot fail" )
488501 + delay
489502 } ) ,
503+ PayloadOptions :: stable ( ) ,
490504 ) {
491505 Ok ( h) => h,
492506 Err ( e) => {
@@ -579,9 +593,11 @@ impl ContextInternal {
579593 let mut inner_lock = must_lock ! ( self . inner) ;
580594 match t. serialize ( ) {
581595 Ok ( b) => {
582- let _ = inner_lock
583- . vm
584- . sys_complete_awakeable ( id. to_owned ( ) , NonEmptyValue :: Success ( b) ) ;
596+ let _ = inner_lock. vm . sys_complete_awakeable (
597+ id. to_owned ( ) ,
598+ NonEmptyValue :: Success ( b) ,
599+ PayloadOptions :: stable ( ) ,
600+ ) ;
585601 }
586602 Err ( e) => {
587603 inner_lock. fail ( Error :: serialization ( "resolve_awakeable" , e) ) ;
@@ -590,9 +606,11 @@ impl ContextInternal {
590606 }
591607
592608 pub fn reject_awakeable ( & self , id : & str , failure : TerminalError ) {
593- let _ = must_lock ! ( self . inner)
594- . vm
595- . sys_complete_awakeable ( id. to_owned ( ) , NonEmptyValue :: Failure ( failure. into ( ) ) ) ;
609+ let _ = must_lock ! ( self . inner) . vm . sys_complete_awakeable (
610+ id. to_owned ( ) ,
611+ NonEmptyValue :: Failure ( failure. into ( ) ) ,
612+ PayloadOptions :: stable ( ) ,
613+ ) ;
596614 }
597615
598616 pub fn promise < T : Deserialize > (
@@ -657,9 +675,11 @@ impl ContextInternal {
657675 let mut inner_lock = must_lock ! ( self . inner) ;
658676 match t. serialize ( ) {
659677 Ok ( b) => {
660- let _ = inner_lock
661- . vm
662- . sys_complete_promise ( name. to_owned ( ) , NonEmptyValue :: Success ( b) ) ;
678+ let _ = inner_lock. vm . sys_complete_promise (
679+ name. to_owned ( ) ,
680+ NonEmptyValue :: Success ( b) ,
681+ PayloadOptions :: stable ( ) ,
682+ ) ;
663683 }
664684 Err ( e) => {
665685 inner_lock. fail (
@@ -674,9 +694,11 @@ impl ContextInternal {
674694 }
675695
676696 pub fn reject_promise ( & self , id : & str , failure : TerminalError ) {
677- let _ = must_lock ! ( self . inner)
678- . vm
679- . sys_complete_promise ( id. to_owned ( ) , NonEmptyValue :: Failure ( failure. into ( ) ) ) ;
697+ let _ = must_lock ! ( self . inner) . vm . sys_complete_promise (
698+ id. to_owned ( ) ,
699+ NonEmptyValue :: Failure ( failure. into ( ) ) ,
700+ PayloadOptions :: stable ( ) ,
701+ ) ;
680702 }
681703
682704 pub fn run < ' a , Run , Fut , Out > (
@@ -719,7 +741,9 @@ impl ContextInternal {
719741 } ,
720742 } ;
721743
722- let _ = inner_lock. vm . sys_write_output ( res_to_write) ;
744+ let _ = inner_lock
745+ . vm
746+ . sys_write_output ( res_to_write, PayloadOptions :: stable ( ) ) ;
723747 inner_lock. maybe_flip_span_replaying_field ( ) ;
724748 }
725749
@@ -886,6 +910,7 @@ where
886910 Ok ( Err ( TerminalError :: from ( TerminalFailure {
887911 code : 409 ,
888912 message : "cancelled" . to_string ( ) ,
913+ metadata : vec ! [ ] ,
889914 } ) ) )
890915 }
891916 . boxed ( ) ,
0 commit comments