//--- Methods --- public async Task <GetBuildResponse> GetBuild(GetBuildRequest request) { var stopwatch = System.Diagnostics.Stopwatch.StartNew(); try { var getBuildTask = _lambdaClient.InvokeAsync(new InvokeRequest { Payload = JsonSerializer.Serialize(new BotRequest { Command = BotCommand.GetBuild, Session = request.Session, Bot = request.Bot }), FunctionName = _lambdaArn, InvocationType = InvocationType.RequestResponse }); // check if lambda responds within time limit if (await Task.WhenAny(getBuildTask, Task.Delay(_requestTimeout)) != getBuildTask) { _logger?.LogInfo($"Bot {_botId} GetBuild timed out after {stopwatch.Elapsed.TotalSeconds:N2}s"); return(null); } var response = Encoding.UTF8.GetString(getBuildTask.Result.Payload.ToArray()); var result = JsonSerializer.Deserialize <BotResponse>(response); _logger?.LogInfo($"Bot {_botId} GetBuild responded in {stopwatch.Elapsed.TotalSeconds:N2}s:\n{response}"); return(result.BotBuild); } catch (Exception e) { _logger?.LogErrorAsInfo(e, $"Bot {_botId} GetBuild failed (arn: {_lambdaArn ?? "<NULL>"})"); return(null); } }