@@ -31,7 +31,7 @@ use temporal_sdk_core_protos::{
3131 coresdk:: {
3232 workflow_activation:: {
3333 create_evict_activation, query_to_job, remove_from_cache:: EvictionReason ,
34- workflow_activation_job, RemoveFromCache , WorkflowActivation ,
34+ workflow_activation_job, WorkflowActivation ,
3535 } ,
3636 workflow_commands:: { FailWorkflowExecution , QueryResult } ,
3737 workflow_completion,
@@ -347,15 +347,8 @@ impl ManagedRun {
347347 }
348348 }
349349 if let Some ( wte) = self . trying_to_evict . clone ( ) {
350- let mut act = self . wfm . machines . get_wf_activation ( ) ;
351- // No other jobs make any sense to send if we encountered an error.
352- if self . am_broken {
353- act. jobs = vec ! [ ] ;
354- }
355- act. append_evict_job ( RemoveFromCache {
356- message : wte. message ,
357- reason : wte. reason as i32 ,
358- } ) ;
350+ let act =
351+ create_evict_activation ( self . run_id ( ) . to_string ( ) , wte. message , wte. reason ) ;
359352 Ok ( Some ( ActivationOrAuto :: LangActivation ( act) ) )
360353 } else {
361354 Ok ( None )
@@ -375,7 +368,7 @@ impl ManagedRun {
375368 used_flags : Vec < u32 > ,
376369 resp_chan : Option < oneshot:: Sender < ActivationCompleteResult > > ,
377370 ) -> Result < RunUpdateAct , NextPageReq > {
378- let activation_was_only_eviction = self . activation_has_only_eviction ( ) ;
371+ let activation_was_only_eviction = self . activation_is_eviction ( ) ;
379372 let ( task_token, has_pending_query, start_time) = if let Some ( entry) = self . wft . as_ref ( ) {
380373 (
381374 entry. info . task_token . clone ( ) ,
@@ -444,15 +437,14 @@ impl ManagedRun {
444437 . collect ( ) ;
445438
446439 if activation_was_only_eviction && !commands. is_empty ( ) {
447- dbg_panic ! ( "Reply to an eviction only containing an eviction included commands" ) ;
440+ dbg_panic ! ( "Reply to an eviction included commands" ) ;
448441 }
449442
450443 let rac = RunActivationCompletion {
451444 task_token,
452445 start_time,
453446 commands,
454- activation_was_eviction : self . activation_has_eviction ( ) ,
455- activation_was_only_eviction,
447+ activation_was_eviction : self . activation_is_eviction ( ) ,
456448 has_pending_query,
457449 query_responses,
458450 used_flags,
@@ -623,7 +615,8 @@ impl ManagedRun {
623615 ) -> ( bool , BufferedTasks ) {
624616 let evict = if self . activation ( ) . map ( pred) . unwrap_or_default ( ) {
625617 let act = self . activation . take ( ) ;
626- act. map ( |a| a. has_eviction ( ) ) . unwrap_or_default ( )
618+ act. map ( |a| matches ! ( a, OutstandingActivation :: Eviction ) )
619+ . unwrap_or_default ( )
627620 } else {
628621 false
629622 } ;
@@ -655,14 +648,14 @@ impl ManagedRun {
655648 task_token : completion. task_token ,
656649 query_responses : completion. query_responses ,
657650 has_pending_query : completion. has_pending_query ,
658- activation_was_only_eviction : completion. activation_was_only_eviction ,
651+ activation_was_eviction : completion. activation_was_eviction ,
659652 } ;
660653
661654 self . wfm . machines . add_lang_used_flags ( completion. used_flags ) ;
662655
663- // If this is just bookkeeping after a reply to an only- eviction activation, we can bypass
656+ // If this is just bookkeeping after a reply to an eviction activation, we can bypass
664657 // everything, since there is no reason to continue trying to update machines.
665- if completion. activation_was_only_eviction {
658+ if completion. activation_was_eviction {
666659 return Ok ( Some ( self . prepare_complete_resp (
667660 completion. resp_chan ,
668661 data,
@@ -793,11 +786,9 @@ impl ManagedRun {
793786 self . trying_to_evict . is_some ( )
794787 } ;
795788 let act_work = if ignore_evicts {
796- if let Some ( ref act) = self . activation {
797- !act. has_only_eviction ( )
798- } else {
799- false
800- }
789+ self . activation
790+ . map ( |a| !matches ! ( a, OutstandingActivation :: Eviction ) )
791+ . unwrap_or_default ( )
801792 } else {
802793 self . activation . is_some ( )
803794 } ;
@@ -854,7 +845,7 @@ impl ManagedRun {
854845 return EvictionRequestResult :: EvictionRequested ( attempts, run_upd) ;
855846 }
856847
857- if !self . activation_has_eviction ( ) && self . trying_to_evict . is_none ( ) {
848+ if !self . activation_is_eviction ( ) && self . trying_to_evict . is_none ( ) {
858849 debug ! ( run_id=%info. run_id, reason=%info. message, "Eviction requested" ) ;
859850 self . trying_to_evict = Some ( info) ;
860851 EvictionRequestResult :: EvictionRequested ( attempts, self . check_more_activations ( ) )
@@ -990,13 +981,12 @@ impl ManagedRun {
990981 fn insert_outstanding_activation ( & mut self , act : & ActivationOrAuto ) {
991982 let act_type = match & act {
992983 ActivationOrAuto :: LangActivation ( act) | ActivationOrAuto :: ReadyForQueries ( act) => {
993- if act. is_legacy_query ( ) {
984+ if act. is_only_eviction ( ) {
985+ OutstandingActivation :: Eviction
986+ } else if act. is_legacy_query ( ) {
994987 OutstandingActivation :: LegacyQuery
995988 } else {
996- OutstandingActivation :: Normal {
997- contains_eviction : act. eviction_index ( ) . is_some ( ) ,
998- num_jobs : act. jobs . len ( ) ,
999- }
989+ OutstandingActivation :: Normal
1000990 }
1001991 }
1002992 ActivationOrAuto :: Autocomplete { .. } | ActivationOrAuto :: AutoFail { .. } => {
@@ -1021,7 +1011,7 @@ impl ManagedRun {
10211011 due_to_heartbeat_timeout : bool ,
10221012 ) -> FulfillableActivationComplete {
10231013 let mut machines_wft_response = self . wfm . prepare_for_wft_response ( ) ;
1024- if data. activation_was_only_eviction
1014+ if data. activation_was_eviction
10251015 && ( machines_wft_response. commands ( ) . peek ( ) . is_some ( )
10261016 || machines_wft_response. has_messages ( ) )
10271017 && !self . am_broken
@@ -1045,7 +1035,7 @@ impl ManagedRun {
10451035 let should_respond = !( machines_wft_response. has_pending_jobs
10461036 || machines_wft_response. replaying
10471037 || is_query_playback
1048- || data. activation_was_only_eviction
1038+ || data. activation_was_eviction
10491039 || machines_wft_response. have_seen_terminal_event ) ;
10501040 // If there are pending LA resolutions, and we're responding to a query here,
10511041 // we want to make sure to force a new task, as otherwise once we tell lang about
@@ -1058,7 +1048,7 @@ impl ManagedRun {
10581048 let outcome = if should_respond || has_query_responses {
10591049 // If we broke there could be commands or messages in the pipe that we didn't
10601050 // get a chance to handle properly during replay. Don't send them.
1061- let ( commands, messages) = if self . am_broken && data. activation_was_only_eviction {
1051+ let ( commands, messages) = if self . am_broken && data. activation_was_eviction {
10621052 ( vec ! [ ] , vec ! [ ] )
10631053 } else {
10641054 (
@@ -1168,15 +1158,9 @@ impl ManagedRun {
11681158 self . wfm . machines . last_processed_event
11691159 }
11701160
1171- fn activation_has_eviction ( & mut self ) -> bool {
1172- self . activation
1173- . map ( OutstandingActivation :: has_eviction)
1174- . unwrap_or_default ( )
1175- }
1176-
1177- fn activation_has_only_eviction ( & mut self ) -> bool {
1161+ fn activation_is_eviction ( & mut self ) -> bool {
11781162 self . activation
1179- . map ( OutstandingActivation :: has_only_eviction )
1163+ . map ( |a| matches ! ( a , OutstandingActivation :: Eviction ) )
11801164 . unwrap_or_default ( )
11811165 }
11821166
@@ -1245,7 +1229,7 @@ struct CompletionDataForWFT {
12451229 task_token : TaskToken ,
12461230 query_responses : Vec < QueryResult > ,
12471231 has_pending_query : bool ,
1248- activation_was_only_eviction : bool ,
1232+ activation_was_eviction : bool ,
12491233}
12501234
12511235/// Manages an instance of a [WorkflowMachines], which is not thread-safe, as well as other data
@@ -1385,7 +1369,6 @@ struct RunActivationCompletion {
13851369 start_time : Instant ,
13861370 commands : Vec < WFCommand > ,
13871371 activation_was_eviction : bool ,
1388- activation_was_only_eviction : bool ,
13891372 has_pending_query : bool ,
13901373 query_responses : Vec < QueryResult > ,
13911374 used_flags : Vec < u32 > ,
0 commit comments