public InvokeData ReceiveInvoke(IDictionary initialEnvironmentVariables, RuntimeReceiveInvokeBuffers buffers) { Console.Error.WriteLine($"START RequestId: {context.RequestId} Version: {context.FunctionVersion}"); invoked = true; var outputStream = new MemoryStream(outputBuffer); outputStream.SetLength(0); curSBSharedMem = new SBSharedMem(sharedMem); return(new InvokeData(curSBSharedMem) { RequestId = context.RequestId, AwsCredentials = new AwsCredentials { AccessKeyId = EnvHelper.GetOrDefault("AWS_ACCESS_KEY_ID", "SOME_ACCESS_KEY_ID"), SecretAccessKey = EnvHelper.GetOrDefault("AWS_SECRET_ACCESS_KEY", "SOME_SECRET_ACCESS_KEY"), SessionToken = System.Environment.GetEnvironmentVariable("AWS_SESSION_TOKEN") }, XAmznTraceId = EnvHelper.GetOrDefault("_X_AMZN_TRACE_ID", ""), InputStream = context.InputStream, OutputStream = outputStream, LambdaContextInternal = new LambdaContextInternal( context.RemainingTime, SendCustomerLogMessage, new Lazy <CognitoClientContextInternal>(), context.RequestId, new Lazy <string>(context.Arn), new Lazy <string>(string.Empty), new Lazy <string>(string.Empty), initialEnvironmentVariables ) }); }
unsafe InvokeData ILambdaRuntime.ReceiveInvoke(IDictionary initialEnvironmentVariables, RuntimeReceiveInvokeBuffers buffers) { if (!invoked) { receivedInvokeAt = DateTimeOffset.Now; invoked = true; } else { logs = ""; } var result = client.GetAsync("http://127.0.0.1:9001/2018-06-01/runtime/invocation/next").Result; if (result.StatusCode != HttpStatusCode.OK) { throw new Exception("Got a bad response from the bootstrap"); } var requestId = result.Headers.GetValues("Lambda-Runtime-Aws-Request-Id").First(); var deadlineMs = result.Headers.GetValues("Lambda-Runtime-Deadline-Ms").First(); var functionArn = result.Headers.GetValues("Lambda-Runtime-Invoked-Function-Arn").First(); var xAmznTraceId = result.Headers.GetValues("Lambda-Runtime-Trace-Id").First(); var clientContext = HeaderHelper.GetFirstOrDefault(result.Headers, "Lambda-Runtime-Client-Context"); var cognitoIdentity = HeaderHelper.GetFirstOrDefault(result.Headers, "Lambda-Runtime-Cognito-Identity"); logTail = HeaderHelper.GetFirstOrDefault(result.Headers, "Docker-Lambda-Log-Type") == "Tail"; var body = result.Content.ReadAsStringAsync().Result; context.RequestId = requestId; context.DeadlineMs = long.Parse(deadlineMs); context.Body = body; curSBSharedMem = new SBSharedMem(sharedMem); return(new InvokeData(curSBSharedMem) { RequestId = context.RequestId, AwsCredentials = new AwsCredentials { AccessKeyId = EnvHelper.GetOrDefault("AWS_ACCESS_KEY_ID", "SOME_ACCESS_KEY_ID"), SecretAccessKey = EnvHelper.GetOrDefault("AWS_SECRET_ACCESS_KEY", "SOME_SECRET_ACCESS_KEY"), SessionToken = System.Environment.GetEnvironmentVariable("AWS_SESSION_TOKEN") }, XAmznTraceId = xAmznTraceId, InputStream = context.InputStream, OutputStream = new UnmanagedMemoryStream(curSBSharedMem.EventBody, 0, SBSharedMem.SizeOfEventBody, FileAccess.Write), LambdaContextInternal = new LambdaContextInternal( context.RemainingTime, SendCustomerLogMessage, GetCognitoClientContextInternalLazy(clientContext), context.RequestId, new Lazy <string>(context.Arn), GetCognitoIdentityIdLazy(cognitoIdentity), GetCognitoIdentityPoolIdLazy(cognitoIdentity), initialEnvironmentVariables ) }); }