@@ -102,18 +102,17 @@ public static TemporalClientConnectOptions LoadClientConnectOptions(
102102 throw new ArgumentException ( "Build ID must be set" , nameof ( version ) ) ;
103103 }
104104
105- var config = new LambdaWorkerConfig
106- {
107- ClientOptions = handlerOptions . LoadClientConnectOptions == null ?
108- new TemporalClientConnectOptions ( ) :
109- handlerOptions . LoadClientConnectOptions ( null ) ,
110- } ;
105+ var loadClientConnectOptions = handlerOptions . LoadClientConnectOptions ;
106+ var config = new LambdaWorkerConfig (
107+ loadClientConnectOptions == null ?
108+ null :
109+ ( ) => loadClientConnectOptions ( null ) ) ;
111110 var environmentTaskQueue = handlerOptions . GetEnvironmentVariable ( TaskQueueEnvironmentVariable ) ;
112111 if ( environmentTaskQueue != null )
113112 {
114113 config . WorkerOptions . TaskQueue = environmentTaskQueue ;
115114 }
116- config . WorkerOptions . DeploymentOptions = new WorkerDeploymentOptions ( version , useWorkerVersioning : true ) ;
115+ ApplyDeploymentVersion ( config . WorkerOptions , version ) ;
117116
118117 configure ( config ) ;
119118 var state = PrepareHandlerState ( version , config , handlerOptions ) ;
@@ -147,17 +146,14 @@ private static LambdaWorkerHandlerState PrepareHandlerState(
147146 "WorkerOptions.TaskQueue must be set or TEMPORAL_TASK_QUEUE must be present" ) ;
148147 }
149148
150- var defaultVersioningBehavior =
151- config . WorkerOptions . DeploymentOptions ? . DefaultVersioningBehavior ??
152- VersioningBehavior . Unspecified ;
153- config . WorkerOptions . DeploymentOptions = new WorkerDeploymentOptions (
154- version ,
155- useWorkerVersioning : true )
149+ var postPluginConfiguration = config . WorkerOptions . PostPluginConfiguration ;
150+ config . WorkerOptions . PostPluginConfiguration = options =>
156151 {
157- DefaultVersioningBehavior = defaultVersioningBehavior ,
152+ postPluginConfiguration ? . Invoke ( options ) ;
153+ ApplyDeploymentVersion ( options , version ) ;
154+ ClearConcurrencyLimitsIfTunerSet ( options ) ;
158155 } ;
159- config . WorkerOptions . BuildId = null ;
160- config . WorkerOptions . UseWorkerVersioning = false ;
156+ config . WorkerOptions . ApplyPostPluginConfiguration ( ) ;
161157
162158 foreach ( var hook in config . ShutdownHooks )
163159 {
@@ -175,6 +171,38 @@ private static LambdaWorkerHandlerState PrepareHandlerState(
175171 handlerOptions ) ;
176172 }
177173
174+ private static void ApplyDeploymentVersion (
175+ TemporalWorkerOptions workerOptions ,
176+ WorkerDeploymentVersion version )
177+ {
178+ var defaultVersioningBehavior =
179+ workerOptions . DeploymentOptions ? . DefaultVersioningBehavior is { } behavior &&
180+ behavior != VersioningBehavior . Unspecified ?
181+ behavior :
182+ VersioningBehavior . AutoUpgrade ;
183+ workerOptions . DeploymentOptions = new WorkerDeploymentOptions (
184+ version ,
185+ useWorkerVersioning : true )
186+ {
187+ DefaultVersioningBehavior = defaultVersioningBehavior ,
188+ } ;
189+ workerOptions . BuildId = null ;
190+ workerOptions . UseWorkerVersioning = false ;
191+ }
192+
193+ private static void ClearConcurrencyLimitsIfTunerSet ( TemporalWorkerOptions workerOptions )
194+ {
195+ if ( workerOptions . Tuner == null )
196+ {
197+ return ;
198+ }
199+
200+ workerOptions . MaxConcurrentActivities = null ;
201+ workerOptions . MaxConcurrentWorkflowTasks = null ;
202+ workerOptions . MaxConcurrentLocalActivities = null ;
203+ workerOptions . MaxConcurrentNexusTasks = null ;
204+ }
205+
178206 private static CancellationTokenSource CreateHookCancellationTokenSource (
179207 TimeSpan remainingTime )
180208 {
0 commit comments