@@ -15,8 +15,9 @@ use temporal_sdk_core::api::errors::PollError;
15
15
use temporal_sdk_core:: replay:: { HistoryForReplay , ReplayWorkerInput } ;
16
16
use temporal_sdk_core_api:: errors:: WorkflowErrorType ;
17
17
use temporal_sdk_core_api:: worker:: {
18
- SlotInfo , SlotInfoTrait , SlotKind , SlotKindType , SlotMarkUsedContext , SlotReleaseContext ,
19
- SlotReservationContext , SlotSupplier as SlotSupplierTrait , SlotSupplierPermit ,
18
+ PollerBehavior , SlotInfo , SlotInfoTrait , SlotKind , SlotKindType , SlotMarkUsedContext ,
19
+ SlotReleaseContext , SlotReservationContext , SlotSupplier as SlotSupplierTrait ,
20
+ SlotSupplierPermit ,
20
21
} ;
21
22
use temporal_sdk_core_api:: Worker ;
22
23
use temporal_sdk_core_protos:: coresdk:: workflow_completion:: WorkflowActivationCompletion ;
@@ -44,7 +45,7 @@ pub struct WorkerRef {
44
45
pub struct WorkerConfig {
45
46
namespace : String ,
46
47
task_queue : String ,
47
- build_id : String ,
48
+ versioning_strategy : WorkerVersioningStrategy ,
48
49
identity_override : Option < String > ,
49
50
max_cached_workflows : usize ,
50
51
tuner : TunerHolder ,
@@ -58,11 +59,34 @@ pub struct WorkerConfig {
58
59
max_activities_per_second : Option < f64 > ,
59
60
max_task_queue_activities_per_second : Option < f64 > ,
60
61
graceful_shutdown_period_millis : u64 ,
61
- use_worker_versioning : bool ,
62
62
nondeterminism_as_workflow_fail : bool ,
63
63
nondeterminism_as_workflow_fail_for_types : HashSet < String > ,
64
64
}
65
65
66
+ /// Recreates [temporal_sdk_core_api::worker::WorkerVersioningStrategy]
67
+ #[ derive( FromPyObject ) ]
68
+ pub enum WorkerVersioningStrategy {
69
+ None { build_id : String } ,
70
+ WorkerDeploymentBased ( WorkerDeploymentOptions ) ,
71
+ LegacyBuildIdBased { build_id : String } ,
72
+ }
73
+
74
+ /// Recreates [temporal_sdk_core_api::worker::WorkerDeploymentOptions]
75
+ #[ derive( FromPyObject ) ]
76
+ pub struct WorkerDeploymentOptions {
77
+ pub version : WorkerDeploymentVersion ,
78
+ pub use_worker_versioning : bool ,
79
+ /// This is a [enums::v1::VersioningBehavior] represented as i32
80
+ pub default_versioning_behavior : i32 ,
81
+ }
82
+
83
+ /// Recreates [temporal_sdk_core_api::worker::WorkerDeploymentVersion]
84
+ #[ derive( FromPyObject ) ]
85
+ pub struct WorkerDeploymentVersion {
86
+ pub deployment_name : String ,
87
+ pub build_id : String ,
88
+ }
89
+
66
90
#[ derive( FromPyObject ) ]
67
91
pub struct TunerHolder {
68
92
workflow_slot_supplier : SlotSupplier ,
@@ -559,16 +583,21 @@ fn convert_worker_config(
559
583
task_locals : Arc < OnceLock < pyo3_asyncio:: TaskLocals > > ,
560
584
) -> PyResult < temporal_sdk_core:: WorkerConfig > {
561
585
let converted_tuner = convert_tuner_holder ( conf. tuner , task_locals) ?;
586
+ let converted_versioning_strategy = convert_versioning_strategy ( conf. versioning_strategy ) ;
562
587
temporal_sdk_core:: WorkerConfigBuilder :: default ( )
563
588
. namespace ( conf. namespace )
564
589
. task_queue ( conf. task_queue )
565
- . worker_build_id ( conf . build_id )
590
+ . versioning_strategy ( converted_versioning_strategy )
566
591
. client_identity_override ( conf. identity_override )
567
592
. max_cached_workflows ( conf. max_cached_workflows )
568
- . max_concurrent_wft_polls ( conf. max_concurrent_workflow_task_polls )
593
+ . workflow_task_poller_behavior ( PollerBehavior :: SimpleMaximum (
594
+ conf. max_concurrent_workflow_task_polls ,
595
+ ) )
569
596
. tuner ( Arc :: new ( converted_tuner) )
570
597
. nonsticky_to_sticky_poll_ratio ( conf. nonsticky_to_sticky_poll_ratio )
571
- . max_concurrent_at_polls ( conf. max_concurrent_activity_task_polls )
598
+ . activity_task_poller_behavior ( PollerBehavior :: SimpleMaximum (
599
+ conf. max_concurrent_activity_task_polls ,
600
+ ) )
572
601
. no_remote_activities ( conf. no_remote_activities )
573
602
. sticky_queue_schedule_to_start_timeout ( Duration :: from_millis (
574
603
conf. sticky_queue_schedule_to_start_timeout_millis ,
@@ -585,7 +614,6 @@ fn convert_worker_config(
585
614
// auto-cancel-activity behavior of shutdown will not occur, so we
586
615
// always set it even if 0.
587
616
. graceful_shutdown_period ( Duration :: from_millis ( conf. graceful_shutdown_period_millis ) )
588
- . use_worker_versioning ( conf. use_worker_versioning )
589
617
. workflow_failure_errors ( if conf. nondeterminism_as_workflow_fail {
590
618
HashSet :: from ( [ WorkflowErrorType :: Nondeterminism ] )
591
619
} else {
@@ -702,6 +730,36 @@ fn convert_slot_supplier<SK: SlotKind + Send + Sync + 'static>(
702
730
} )
703
731
}
704
732
733
+ fn convert_versioning_strategy (
734
+ strategy : WorkerVersioningStrategy ,
735
+ ) -> temporal_sdk_core_api:: worker:: WorkerVersioningStrategy {
736
+ match strategy {
737
+ WorkerVersioningStrategy :: None { build_id } => {
738
+ temporal_sdk_core_api:: worker:: WorkerVersioningStrategy :: None { build_id }
739
+ }
740
+ WorkerVersioningStrategy :: WorkerDeploymentBased ( worker_deployment_options) => {
741
+ temporal_sdk_core_api:: worker:: WorkerVersioningStrategy :: WorkerDeploymentBased (
742
+ temporal_sdk_core_api:: worker:: WorkerDeploymentOptions {
743
+ version : temporal_sdk_core_api:: worker:: WorkerDeploymentVersion {
744
+ deployment_name : worker_deployment_options. version . deployment_name ,
745
+ build_id : worker_deployment_options. version . build_id ,
746
+ } ,
747
+ use_worker_versioning : worker_deployment_options. use_worker_versioning ,
748
+ default_versioning_behavior : Some (
749
+ worker_deployment_options
750
+ . default_versioning_behavior
751
+ . try_into ( )
752
+ . unwrap_or_default ( ) ,
753
+ ) ,
754
+ } ,
755
+ )
756
+ }
757
+ WorkerVersioningStrategy :: LegacyBuildIdBased { build_id } => {
758
+ temporal_sdk_core_api:: worker:: WorkerVersioningStrategy :: LegacyBuildIdBased { build_id }
759
+ }
760
+ }
761
+ }
762
+
705
763
/// For feeding histories into core during replay
706
764
#[ pyclass]
707
765
pub struct HistoryPusher {
0 commit comments