@@ -31,7 +31,7 @@ use temporal_sdk_core_protos::{
31
31
coresdk:: {
32
32
workflow_activation:: {
33
33
create_evict_activation, query_to_job, remove_from_cache:: EvictionReason ,
34
- workflow_activation_job, RemoveFromCache , WorkflowActivation ,
34
+ workflow_activation_job, WorkflowActivation ,
35
35
} ,
36
36
workflow_commands:: { FailWorkflowExecution , QueryResult } ,
37
37
workflow_completion,
@@ -347,15 +347,8 @@ impl ManagedRun {
347
347
}
348
348
}
349
349
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 ) ;
359
352
Ok ( Some ( ActivationOrAuto :: LangActivation ( act) ) )
360
353
} else {
361
354
Ok ( None )
@@ -375,7 +368,7 @@ impl ManagedRun {
375
368
used_flags : Vec < u32 > ,
376
369
resp_chan : Option < oneshot:: Sender < ActivationCompleteResult > > ,
377
370
) -> Result < RunUpdateAct , NextPageReq > {
378
- let activation_was_only_eviction = self . activation_has_only_eviction ( ) ;
371
+ let activation_was_only_eviction = self . activation_is_eviction ( ) ;
379
372
let ( task_token, has_pending_query, start_time) = if let Some ( entry) = self . wft . as_ref ( ) {
380
373
(
381
374
entry. info . task_token . clone ( ) ,
@@ -444,15 +437,14 @@ impl ManagedRun {
444
437
. collect ( ) ;
445
438
446
439
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" ) ;
448
441
}
449
442
450
443
let rac = RunActivationCompletion {
451
444
task_token,
452
445
start_time,
453
446
commands,
454
- activation_was_eviction : self . activation_has_eviction ( ) ,
455
- activation_was_only_eviction,
447
+ activation_was_eviction : self . activation_is_eviction ( ) ,
456
448
has_pending_query,
457
449
query_responses,
458
450
used_flags,
@@ -623,7 +615,8 @@ impl ManagedRun {
623
615
) -> ( bool , BufferedTasks ) {
624
616
let evict = if self . activation ( ) . map ( pred) . unwrap_or_default ( ) {
625
617
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 ( )
627
620
} else {
628
621
false
629
622
} ;
@@ -655,14 +648,14 @@ impl ManagedRun {
655
648
task_token : completion. task_token ,
656
649
query_responses : completion. query_responses ,
657
650
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 ,
659
652
} ;
660
653
661
654
self . wfm . machines . add_lang_used_flags ( completion. used_flags ) ;
662
655
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
664
657
// 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 {
666
659
return Ok ( Some ( self . prepare_complete_resp (
667
660
completion. resp_chan ,
668
661
data,
@@ -793,11 +786,9 @@ impl ManagedRun {
793
786
self . trying_to_evict . is_some ( )
794
787
} ;
795
788
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 ( )
801
792
} else {
802
793
self . activation . is_some ( )
803
794
} ;
@@ -854,7 +845,7 @@ impl ManagedRun {
854
845
return EvictionRequestResult :: EvictionRequested ( attempts, run_upd) ;
855
846
}
856
847
857
- if !self . activation_has_eviction ( ) && self . trying_to_evict . is_none ( ) {
848
+ if !self . activation_is_eviction ( ) && self . trying_to_evict . is_none ( ) {
858
849
debug ! ( run_id=%info. run_id, reason=%info. message, "Eviction requested" ) ;
859
850
self . trying_to_evict = Some ( info) ;
860
851
EvictionRequestResult :: EvictionRequested ( attempts, self . check_more_activations ( ) )
@@ -990,13 +981,12 @@ impl ManagedRun {
990
981
fn insert_outstanding_activation ( & mut self , act : & ActivationOrAuto ) {
991
982
let act_type = match & act {
992
983
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 ( ) {
994
987
OutstandingActivation :: LegacyQuery
995
988
} else {
996
- OutstandingActivation :: Normal {
997
- contains_eviction : act. eviction_index ( ) . is_some ( ) ,
998
- num_jobs : act. jobs . len ( ) ,
999
- }
989
+ OutstandingActivation :: Normal
1000
990
}
1001
991
}
1002
992
ActivationOrAuto :: Autocomplete { .. } | ActivationOrAuto :: AutoFail { .. } => {
@@ -1021,7 +1011,7 @@ impl ManagedRun {
1021
1011
due_to_heartbeat_timeout : bool ,
1022
1012
) -> FulfillableActivationComplete {
1023
1013
let mut machines_wft_response = self . wfm . prepare_for_wft_response ( ) ;
1024
- if data. activation_was_only_eviction
1014
+ if data. activation_was_eviction
1025
1015
&& ( machines_wft_response. commands ( ) . peek ( ) . is_some ( )
1026
1016
|| machines_wft_response. has_messages ( ) )
1027
1017
&& !self . am_broken
@@ -1045,7 +1035,7 @@ impl ManagedRun {
1045
1035
let should_respond = !( machines_wft_response. has_pending_jobs
1046
1036
|| machines_wft_response. replaying
1047
1037
|| is_query_playback
1048
- || data. activation_was_only_eviction
1038
+ || data. activation_was_eviction
1049
1039
|| machines_wft_response. have_seen_terminal_event ) ;
1050
1040
// If there are pending LA resolutions, and we're responding to a query here,
1051
1041
// we want to make sure to force a new task, as otherwise once we tell lang about
@@ -1058,7 +1048,7 @@ impl ManagedRun {
1058
1048
let outcome = if should_respond || has_query_responses {
1059
1049
// If we broke there could be commands or messages in the pipe that we didn't
1060
1050
// 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 {
1062
1052
( vec ! [ ] , vec ! [ ] )
1063
1053
} else {
1064
1054
(
@@ -1168,15 +1158,9 @@ impl ManagedRun {
1168
1158
self . wfm . machines . last_processed_event
1169
1159
}
1170
1160
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 {
1178
1162
self . activation
1179
- . map ( OutstandingActivation :: has_only_eviction )
1163
+ . map ( |a| matches ! ( a , OutstandingActivation :: Eviction ) )
1180
1164
. unwrap_or_default ( )
1181
1165
}
1182
1166
@@ -1245,7 +1229,7 @@ struct CompletionDataForWFT {
1245
1229
task_token : TaskToken ,
1246
1230
query_responses : Vec < QueryResult > ,
1247
1231
has_pending_query : bool ,
1248
- activation_was_only_eviction : bool ,
1232
+ activation_was_eviction : bool ,
1249
1233
}
1250
1234
1251
1235
/// Manages an instance of a [WorkflowMachines], which is not thread-safe, as well as other data
@@ -1385,7 +1369,6 @@ struct RunActivationCompletion {
1385
1369
start_time : Instant ,
1386
1370
commands : Vec < WFCommand > ,
1387
1371
activation_was_eviction : bool ,
1388
- activation_was_only_eviction : bool ,
1389
1372
has_pending_query : bool ,
1390
1373
query_responses : Vec < QueryResult > ,
1391
1374
used_flags : Vec < u32 > ,
0 commit comments