public void Run_SetsXrayEnvironmentVariableBeforeCallingHandle() { // arrange A.CallTo(() => _runtime.KeepInvokeLoopRunning()).ReturnsNextFromSequence(true, false); var invokeData = new InvokeData { XAmznTraceId = Guid.NewGuid().ToString(), InputStream = new MemoryStream(), LambdaContext = A.Fake <ILambdaContext>() }; A.CallTo(() => _runtime.GetNextInvocation()).Returns(invokeData); var environment = A.Fake <IEnvironment>(); A.CallTo(() => _runtime.Environment).Returns(environment); // act _bootstrap.Run(); // assert A.CallTo(() => environment.SetEnvironmentVariable("_X_AMZN_TRACE_ID", invokeData.XAmznTraceId)) .MustHaveHappened() .Then(A.CallTo(() => _runner.Handle(invokeData.InputStream, invokeData.LambdaContext)).MustHaveHappened()); }
private static void Run(IHandlerRunner runner) { ILambdaRuntime runtime = new LambdaRuntime(new SystemEnvironment(), new SystemDateTime(), new HttpClient()); ILambdaBootstrap bootstrap = new LambdaBootstrap(runtime, runner); bootstrap.Initialize(); bootstrap.Run(); }
private static void Run(IHandlerRunner runner) { // The Lambda container freezes the process at a point where an HTTP request is in progress. // We need to make sure we don't timeout waiting for the next invocation. // Reference 12 Hours from AWS Custom Runtime Support HttpClient httpClient = new HttpClient(); httpClient.Timeout = TimeSpan.FromHours(12); ILambdaRuntime runtime = new LambdaRuntime(new SystemEnvironment(), new SystemDateTime(), httpClient); ILambdaBootstrap bootstrap = new LambdaBootstrap(runtime, runner); bootstrap.Initialize(); bootstrap.Run(); }