@@ -34,7 +34,7 @@ public Processor(GrpcDurableTaskWorker worker, TaskHubSidecarServiceClient sidec
3434 {
3535 this . worker = worker ;
3636 this . sidecar = sidecar ;
37- this . shimFactory = new DurableTaskShimFactory ( this . worker . options , this . worker . loggerFactory ) ;
37+ this . shimFactory = new DurableTaskShimFactory ( this . worker . grpcOptions , this . worker . loggerFactory ) ;
3838 }
3939
4040 ILogger Logger => this . worker . logger ;
@@ -102,7 +102,7 @@ static OrchestrationRuntimeState BuildRuntimeState(P.OrchestratorRequest request
102102
103103 if ( runtimeState . ExecutionStartedEvent == null )
104104 {
105- // TODO: What's the right way to handle this? Callback to the sidecar with a retryable error request?
105+ // TODO: What's the right way to handle this? Callback to the sidecar with a retriable error request?
106106 throw new InvalidOperationException ( "The provided orchestration history was incomplete" ) ;
107107 }
108108
@@ -133,8 +133,18 @@ static string GetActionsListForLogging(IReadOnlyList<P.OrchestratorAction> actio
133133 await this . sidecar ! . HelloAsync ( EmptyMessage , cancellationToken : cancellation ) ;
134134 this . Logger . EstablishedWorkItemConnection ( ) ;
135135
136+ DurableTaskWorkerOptions workerOptions = this . worker . workerOptions ;
137+
136138 // Get the stream for receiving work-items
137- return this . sidecar ! . GetWorkItems ( new P . GetWorkItemsRequest ( ) , cancellationToken : cancellation ) ;
139+ return this . sidecar ! . GetWorkItems (
140+ new P . GetWorkItemsRequest
141+ {
142+ MaxConcurrentActivityWorkItems =
143+ workerOptions . Concurrency . MaximumConcurrentActivityWorkItems ,
144+ MaxConcurrentOrchestrationWorkItems =
145+ workerOptions . Concurrency . MaximumConcurrentOrchestrationWorkItems ,
146+ } ,
147+ cancellationToken : cancellation ) ;
138148 }
139149
140150 async Task ProcessWorkItemsAsync ( AsyncServerStreamingCall < P . WorkItem > stream , CancellationToken cancellation )
@@ -145,16 +155,25 @@ async Task ProcessWorkItemsAsync(AsyncServerStreamingCall<P.WorkItem> stream, Ca
145155 {
146156 if ( workItem . RequestCase == P . WorkItem . RequestOneofCase . OrchestratorRequest )
147157 {
148- this . RunBackgroundTask ( workItem , ( ) => this . OnRunOrchestratorAsync (
149- workItem . OrchestratorRequest ) ) ;
158+ this . RunBackgroundTask (
159+ workItem ,
160+ ( ) => this . OnRunOrchestratorAsync ( workItem . OrchestratorRequest , workItem . CompletionToken ) ) ;
150161 }
151162 else if ( workItem . RequestCase == P . WorkItem . RequestOneofCase . ActivityRequest )
152163 {
153- this . RunBackgroundTask ( workItem , ( ) => this . OnRunActivityAsync ( workItem . ActivityRequest ) ) ;
164+ this . RunBackgroundTask (
165+ workItem ,
166+ ( ) => this . OnRunActivityAsync ( workItem . ActivityRequest , workItem . CompletionToken ) ) ;
154167 }
155168 else if ( workItem . RequestCase == P . WorkItem . RequestOneofCase . EntityRequest )
156169 {
157- this . RunBackgroundTask ( workItem , ( ) => this . OnRunEntityBatchAsync ( workItem . EntityRequest ) ) ;
170+ this . RunBackgroundTask (
171+ workItem ,
172+ ( ) => this . OnRunEntityBatchAsync ( workItem . EntityRequest ) ) ;
173+ }
174+ else if ( workItem . RequestCase == P . WorkItem . RequestOneofCase . HealthPing )
175+ {
176+ // No-op
158177 }
159178 else
160179 {
@@ -188,7 +207,7 @@ void RunBackgroundTask(P.WorkItem? workItem, Func<Task> handler)
188207 } ) ;
189208 }
190209
191- async Task OnRunOrchestratorAsync ( P . OrchestratorRequest request )
210+ async Task OnRunOrchestratorAsync ( P . OrchestratorRequest request , string completionToken )
192211 {
193212 OrchestratorExecutionResult ? result = null ;
194213 P . TaskFailureDetails ? failureDetails = null ;
@@ -248,14 +267,16 @@ async Task OnRunOrchestratorAsync(P.OrchestratorRequest request)
248267 response = ProtoUtils . ConstructOrchestratorResponse (
249268 request . InstanceId ,
250269 result . CustomStatus ,
251- result . Actions ) ;
270+ result . Actions ,
271+ completionToken ) ;
252272 }
253273 else
254274 {
255275 // This is the case for failures that happened *outside* the orchestrator executor
256276 response = new P . OrchestratorResponse
257277 {
258278 InstanceId = request . InstanceId ,
279+ CompletionToken = completionToken ,
259280 Actions =
260281 {
261282 new P . OrchestratorAction
@@ -279,7 +300,7 @@ async Task OnRunOrchestratorAsync(P.OrchestratorRequest request)
279300 await this . sidecar . CompleteOrchestratorTaskAsync ( response ) ;
280301 }
281302
282- async Task OnRunActivityAsync ( P . ActivityRequest request )
303+ async Task OnRunActivityAsync ( P . ActivityRequest request , string completionToken )
283304 {
284305 OrchestrationInstance instance = request . OrchestrationInstance . ToCore ( ) ;
285306 string rawInput = request . Input ;
@@ -336,6 +357,7 @@ async Task OnRunActivityAsync(P.ActivityRequest request)
336357 TaskId = request . TaskId ,
337358 Result = output ,
338359 FailureDetails = failureDetails ,
360+ CompletionToken = completionToken ,
339361 } ;
340362
341363 await this . sidecar . CompleteActivityTaskAsync ( response ) ;
0 commit comments