@@ -7,6 +7,7 @@ use temporal_client::{
77 Client , IsWorkerTaskLongPoll , Namespace , NamespacedClient , NoRetryOnMatching , RetryClient ,
88 SlotManager , WorkflowService ,
99} ;
10+ use temporal_sdk_core_api:: worker:: WorkerVersioningStrategy ;
1011use temporal_sdk_core_protos:: {
1112 TaskToken ,
1213 coresdk:: workflow_commands:: QueryResult ,
@@ -16,7 +17,10 @@ use temporal_sdk_core_protos::{
1617 MeteringMetadata , Payloads , WorkerVersionCapabilities , WorkerVersionStamp ,
1718 WorkflowExecution ,
1819 } ,
19- enums:: v1:: { TaskQueueKind , WorkflowTaskFailedCause } ,
20+ deployment,
21+ enums:: v1:: {
22+ TaskQueueKind , VersioningBehavior , WorkerVersioningMode , WorkflowTaskFailedCause ,
23+ } ,
2024 failure:: v1:: Failure ,
2125 nexus,
2226 protocol:: v1:: Message as ProtocolMessage ,
@@ -35,24 +39,21 @@ pub(crate) struct WorkerClientBag {
3539 replaceable_client : RwLock < RetryClient < Client > > ,
3640 namespace : String ,
3741 identity : String ,
38- worker_build_id : String ,
39- use_versioning : bool ,
42+ worker_versioning_strategy : WorkerVersioningStrategy ,
4043}
4144
4245impl WorkerClientBag {
4346 pub ( crate ) fn new (
4447 client : RetryClient < Client > ,
4548 namespace : String ,
4649 identity : String ,
47- worker_build_id : String ,
48- use_versioning : bool ,
50+ worker_versioning_strategy : WorkerVersioningStrategy ,
4951 ) -> Self {
5052 Self {
5153 replaceable_client : RwLock :: new ( client) ,
5254 namespace,
5355 identity,
54- worker_build_id,
55- use_versioning,
56+ worker_versioning_strategy,
5657 }
5758 }
5859
@@ -68,16 +69,34 @@ impl WorkerClientBag {
6869 if self . default_capabilities ( ) . build_id_based_versioning {
6970 "" . to_string ( )
7071 } else {
71- self . worker_build_id . clone ( )
72+ self . worker_versioning_strategy . build_id ( ) . to_owned ( )
73+ }
74+ }
75+
76+ fn deployment_options ( & self ) -> Option < deployment:: v1:: WorkerDeploymentOptions > {
77+ match & self . worker_versioning_strategy {
78+ WorkerVersioningStrategy :: WorkerDeploymentBased ( dopts) => {
79+ Some ( deployment:: v1:: WorkerDeploymentOptions {
80+ deployment_name : dopts. version . deployment_name . clone ( ) ,
81+ build_id : dopts. version . build_id . clone ( ) ,
82+ worker_versioning_mode : if dopts. use_worker_versioning {
83+ WorkerVersioningMode :: Versioned . into ( )
84+ } else {
85+ WorkerVersioningMode :: Unversioned . into ( )
86+ } ,
87+ } )
88+ }
89+ _ => None ,
7290 }
7391 }
7492
7593 fn worker_version_capabilities ( & self ) -> Option < WorkerVersionCapabilities > {
7694 if self . default_capabilities ( ) . build_id_based_versioning {
7795 Some ( WorkerVersionCapabilities {
78- build_id : self . worker_build_id . clone ( ) ,
79- use_versioning : self . use_versioning ,
80- // TODO: https://github.com/temporalio/sdk-core/issues/866
96+ build_id : self . worker_versioning_strategy . build_id ( ) . to_owned ( ) ,
97+ use_versioning : self . worker_versioning_strategy . uses_build_id_based ( ) ,
98+ // This will never be used, as it is the v3 version that we never supported in
99+ // Core SDKs.
81100 deployment_series_name : "" . to_string ( ) ,
82101 } )
83102 } else {
@@ -88,8 +107,8 @@ impl WorkerClientBag {
88107 fn worker_version_stamp ( & self ) -> Option < WorkerVersionStamp > {
89108 if self . default_capabilities ( ) . build_id_based_versioning {
90109 Some ( WorkerVersionStamp {
91- build_id : self . worker_build_id . clone ( ) ,
92- use_versioning : self . use_versioning ,
110+ build_id : self . worker_versioning_strategy . build_id ( ) . to_owned ( ) ,
111+ use_versioning : self . worker_versioning_strategy . uses_build_id_based ( ) ,
93112 } )
94113 } else {
95114 None
@@ -221,8 +240,7 @@ impl WorkerClient for WorkerClientBag {
221240 identity : self . identity . clone ( ) ,
222241 binary_checksum : self . binary_checksum ( ) ,
223242 worker_version_capabilities : self . worker_version_capabilities ( ) ,
224- // TODO: https://github.com/temporalio/sdk-core/issues/866
225- deployment_options : None ,
243+ deployment_options : self . deployment_options ( ) ,
226244 }
227245 . into_request ( ) ;
228246 request. extensions_mut ( ) . insert ( IsWorkerTaskLongPoll ) ;
@@ -258,8 +276,7 @@ impl WorkerClient for WorkerClientBag {
258276 max_tasks_per_second : Some ( tps) ,
259277 } ) ,
260278 worker_version_capabilities : self . worker_version_capabilities ( ) ,
261- // TODO: https://github.com/temporalio/sdk-core/issues/866
262- deployment_options : None ,
279+ deployment_options : self . deployment_options ( ) ,
263280 }
264281 . into_request ( ) ;
265282 request. extensions_mut ( ) . insert ( IsWorkerTaskLongPoll ) ;
@@ -291,8 +308,7 @@ impl WorkerClient for WorkerClientBag {
291308 } ) ,
292309 identity : self . identity . clone ( ) ,
293310 worker_version_capabilities : self . worker_version_capabilities ( ) ,
294- // TODO: https://github.com/temporalio/sdk-core/issues/866
295- deployment_options : None ,
311+ deployment_options : self . deployment_options ( ) ,
296312 }
297313 . into_request ( ) ;
298314 request. extensions_mut ( ) . insert ( IsWorkerTaskLongPoll ) ;
@@ -348,11 +364,10 @@ impl WorkerClient for WorkerClientBag {
348364 capabilities : Some ( respond_workflow_task_completed_request:: Capabilities {
349365 discard_speculative_workflow_task_with_events : true ,
350366 } ) ,
351- // TODO: https://github.com/temporalio/sdk-core/issues/866
367+ // Will never be set, deprecated.
352368 deployment : None ,
353- versioning_behavior : 0 ,
354- // TODO: https://github.com/temporalio/sdk-core/issues/866
355- deployment_options : None ,
369+ versioning_behavior : request. versioning_behavior . into ( ) ,
370+ deployment_options : self . deployment_options ( ) ,
356371 } ;
357372 Ok ( self
358373 . cloned_client ( )
@@ -638,4 +653,6 @@ pub(crate) struct WorkflowTaskCompletion {
638653 pub ( crate ) sdk_metadata : WorkflowTaskCompletedMetadata ,
639654 /// Metering info
640655 pub ( crate ) metering_metadata : MeteringMetadata ,
656+ /// Versioning behavior of the workflow, if any.
657+ pub ( crate ) versioning_behavior : VersioningBehavior ,
641658}
0 commit comments