@@ -51,7 +51,7 @@ use std::{
5151 sync:: Arc ,
5252 time:: { Duration , Instant , SystemTime } ,
5353} ;
54- use temporal_sdk_core_api:: worker:: WorkerConfig ;
54+ use temporal_sdk_core_api:: worker:: { WorkerConfig , WorkerDeploymentVersion } ;
5555use temporal_sdk_core_protos:: {
5656 coresdk:: {
5757 common:: { NamespacedWorkflowExecution , VersioningIntent } ,
@@ -123,8 +123,9 @@ pub(crate) struct WorkflowMachines {
123123 history_size_bytes : u64 ,
124124 /// Set on each WFT started event
125125 continue_as_new_suggested : bool ,
126- /// Set if the current WFT is already complete and that completion event had a build id in it.
127- current_wft_build_id : Option < String > ,
126+ /// Set if the current WFT is already complete and that completion event had legacy build-id
127+ /// or a deployment version in it. Will use an empty deployment name if it's legacy build-id.
128+ current_wft_deployment_info : Option < WorkerDeploymentVersion > ,
128129
129130 all_machines : SlotMap < MachineKey , Machines > ,
130131 /// If a machine key is in this map, that machine was created internally by core, not as a
@@ -286,7 +287,7 @@ impl WorkflowMachines {
286287 observed_internal_flags : Rc :: new ( RefCell :: new ( observed_internal_flags) ) ,
287288 history_size_bytes : 0 ,
288289 continue_as_new_suggested : false ,
289- current_wft_build_id : None ,
290+ current_wft_deployment_info : None ,
290291 all_machines : Default :: default ( ) ,
291292 machine_is_core_created : Default :: default ( ) ,
292293 machines_by_event_id : Default :: default ( ) ,
@@ -442,11 +443,11 @@ impl WorkflowMachines {
442443 )
443444 } ) ;
444445 let is_replaying = self . replaying || all_query;
445- let build_id_for_current_task = if is_replaying {
446- self . current_wft_build_id . clone ( ) . unwrap_or_default ( )
446+ let deployment_version_for_current_task = if is_replaying {
447+ self . current_wft_deployment_info . clone ( )
447448 } else {
448- self . current_wft_build_id = Some ( self . worker_config . build_id ( ) . to_owned ( ) ) ;
449- self . worker_config . build_id ( ) . to_owned ( )
449+ self . current_wft_deployment_info = self . worker_config . computed_deployment_version ( ) ;
450+ self . current_wft_deployment_info . clone ( )
450451 } ;
451452 WorkflowActivation {
452453 timestamp : self . current_wf_time . map ( Into :: into) ,
@@ -460,7 +461,8 @@ impl WorkflowMachines {
460461 . collect ( ) ,
461462 history_size_bytes : self . history_size_bytes ,
462463 continue_as_new_suggested : self . continue_as_new_suggested ,
463- build_id_for_current_task,
464+ deployment_version_for_current_task : deployment_version_for_current_task
465+ . map ( Into :: into) ,
464466 }
465467 }
466468
@@ -479,9 +481,7 @@ impl WorkflowMachines {
479481 // If this worker has a build ID and we're completing the task, we want to say our ID is the
480482 // current build ID, so that if we get a query before any new history, we properly can
481483 // report that our ID was the one used for the completion.
482- if !self . worker_config . build_id ( ) . is_empty ( ) {
483- self . current_wft_build_id = Some ( self . worker_config . build_id ( ) . to_owned ( ) ) ;
484- }
484+ self . current_wft_deployment_info = self . worker_config . computed_deployment_version ( ) ;
485485 ( * self . observed_internal_flags )
486486 . borrow_mut ( )
487487 . gather_for_wft_complete ( )
@@ -587,8 +587,23 @@ impl WorkflowMachines {
587587 ( * $me. observed_internal_flags)
588588 . borrow_mut( )
589589 . add_from_complete( $wtc) ;
590+ let mut combined_ver = WorkerDeploymentVersion {
591+ deployment_name: "" . to_string( ) ,
592+ build_id: "" . to_string( ) ,
593+ } ;
590594 if let Some ( bid) = $wtc. worker_version. as_ref( ) . map( |wv| & wv. build_id) {
591- $me. current_wft_build_id = Some ( bid. to_string( ) ) ;
595+ combined_ver. build_id = bid. to_string( ) ;
596+ }
597+ if !$wtc. worker_deployment_name. is_empty( ) {
598+ combined_ver. deployment_name = $wtc. worker_deployment_name. clone( ) ;
599+ }
600+ if !$wtc. worker_deployment_version. is_empty( ) {
601+ if let Ok ( ver) = $wtc. worker_deployment_version. parse( ) {
602+ combined_ver = ver;
603+ }
604+ }
605+ if !combined_ver. is_empty( ) {
606+ $me. current_wft_deployment_info = Some ( combined_ver) ;
592607 }
593608 } } ;
594609 }
0 commit comments