internal async Task ProcessRequestLoop() { using (_msgStream) { StreamingMessage request, response; while (await _msgStream.MoveNext()) { request = _msgStream.GetCurrentMessage(); using (_logger.BeginScope(request.RequestId, request.InvocationRequest?.InvocationId)) { switch (request.ContentCase) { case StreamingMessage.ContentOneofCase.WorkerInitRequest: response = ProcessWorkerInitRequest(request); break; case StreamingMessage.ContentOneofCase.FunctionLoadRequest: response = ProcessFunctionLoadRequest(request); break; case StreamingMessage.ContentOneofCase.InvocationRequest: response = ProcessInvocationRequest(request); break; default: throw new InvalidOperationException($"Not supportted message type: {request.ContentCase}"); } } await _msgStream.WriteAsync(response); } } }