in src/RequestProcessor.cs [271:318]
internal StreamingMessage ProcessInvocationRequest(StreamingMessage request)
{
try
{
var stopwatch = new FunctionInvocationPerformanceStopwatch();
stopwatch.OnStart();
// Will block if installing dependencies is required
_dependencyManager.WaitForDependenciesAvailability(
() =>
{
var rpcLogger = new RpcLogger(_msgStream);
rpcLogger.SetContext(request.RequestId, request.InvocationRequest?.InvocationId);
return rpcLogger;
});
stopwatch.OnCheckpoint(FunctionInvocationPerformanceStopwatch.Checkpoint.DependenciesAvailable);
AzFunctionInfo functionInfo = FunctionLoader.GetFunctionInfo(request.InvocationRequest.FunctionId);
PowerShellManager psManager = _powershellPool.CheckoutIdleWorker(
request.RequestId,
request.InvocationRequest?.InvocationId,
functionInfo.FuncName,
functionInfo.OutputBindings);
stopwatch.OnCheckpoint(FunctionInvocationPerformanceStopwatch.Checkpoint.RunspaceAvailable);
// When the concurrency upper bound is more than 1, we have to handle the invocation in a worker
// thread, so multiple invocations can make progress at the same time, even though by time-sharing.
Task.Run(() => ProcessInvocationRequestImpl(request, functionInfo, psManager, stopwatch));
}
catch (Exception e)
{
StreamingMessage response = NewStreamingMessageTemplate(
request.RequestId,
StreamingMessage.ContentOneofCase.InvocationResponse,
out StatusResult status);
response.InvocationResponse.InvocationId = request.InvocationRequest.InvocationId;
status.Status = StatusResult.Types.Status.Failure;
status.Exception = e.ToRpcException();
return response;
}
return null;
}