public LambdaContext(RuntimeApiHeaders runtimeApiHeaders, LambdaEnvironment lambdaEnvironment) { _lambdaEnvironment = lambdaEnvironment; _runtimeApiHeaders = runtimeApiHeaders; int.TryParse(_lambdaEnvironment.FunctionMemorySize, out _memoryLimitInMB); long.TryParse(_runtimeApiHeaders.DeadlineMs, out _deadlineMs); _cognitoIdentityLazy = new Lazy <CognitoIdentity>(() => CognitoIdentity.FromJson(runtimeApiHeaders.CognitoIdentityJson)); _cognitoClientContextLazy = new Lazy <CognitoClientContext>(() => CognitoClientContext.FromJson(runtimeApiHeaders.ClientContextJson)); // set environment variable so that if the function uses the XRay client it will work correctly _lambdaEnvironment.SetXAmznTraceId(_runtimeApiHeaders.TraceId); }
/// <summary> /// Get the next function invocation from the Runtime API as an asynchronous operation. /// Completes when the next invocation is received. /// </summary> /// <param name="cancellationToken">The optional cancellation token to use to stop listening for the next invocation.</param> /// <returns>A Task representing the asynchronous operation.</returns> public async Task <InvocationRequest> GetNextInvocationAsync(CancellationToken cancellationToken = default) { SwaggerResponse <Stream> response = await _internalClient.NextAsync(cancellationToken); var headers = new RuntimeApiHeaders(response.Headers); _consoleLoggerRedirector.SetCurrentAwsRequestId(headers.AwsRequestId); var lambdaContext = new LambdaContext(headers, LambdaEnvironment, _consoleLoggerRedirector); return(new InvocationRequest { InputStream = response.Result, LambdaContext = lambdaContext, }); }
public LambdaContext(RuntimeApiHeaders runtimeApiHeaders, LambdaEnvironment lambdaEnvironment) : this(runtimeApiHeaders, lambdaEnvironment, new DateTimeHelper()) { }
public LambdaContext(RuntimeApiHeaders runtimeApiHeaders, LambdaEnvironment lambdaEnvironment, IConsoleLoggerWriter consoleLogger) : this(runtimeApiHeaders, lambdaEnvironment, new DateTimeHelper(), consoleLogger) { }