Exemplo n.º 1
0
 public Startup(LambdaTestHostSettings settings)
 {
     _settings          = settings;
     _lambdaAccountPool = new LambdaAccountPool(
         settings.AccountConcurrencyLimit,
         settings.Functions);
 }
Exemplo n.º 2
0
        public static async ValueTask <LambdaTestHost> Start(LambdaTestHostSettings settings)
        {
            var host = WebHost
                       .CreateDefaultBuilder <Startup>(Array.Empty <string>())
                       .UseUrls(settings.WebHostUrl)
                       .ConfigureLogging(settings.ConfigureLogging)
                       .ConfigureServices(services =>
            {
                services.AddSingleton(settings);
            })
                       .Build();

            await host.StartAsync();

            var serviceUrl = host.GetServerUris().Single();

            return(new LambdaTestHost(settings, host, serviceUrl));
        }
Exemplo n.º 3
0
        public async Task InitializeAsync()
        {
            _settings = new LambdaTestHostSettings(() => new TestLambdaContext
            {
                Logger = new XunitLambdaLogger(_outputHelper),
            });

            _settings.AddFunction(
                new LambdaFunctionInfo(
                    nameof(BrokenFunction),
                    typeof(BrokenFunction),
                    nameof(BrokenFunction.Handle)));

            _settings.AddFunction(
                new LambdaFunctionInfo(
                    nameof(APIGatewayFunction),
                    typeof(APIGatewayFunction),
                    nameof(APIGatewayFunction.Handle)));

            _settings.AddFunction(
                new LambdaFunctionInfo(
                    nameof(ReverseStringFunction),
                    typeof(ReverseStringFunction),
                    nameof(ReverseStringFunction.Reverse)));

            _settings.AddFunction(
                new LambdaFunctionInfo(
                    nameof(SleepFunction),
                    typeof(SleepFunction),
                    nameof(SleepFunction.Handle),
                    1));

            _testHost = await LambdaTestHost.Start(_settings);

            var awsCredentials = new BasicAWSCredentials("not", "used");
            var lambdaConfig   = new AmazonLambdaConfig
            {
                ServiceURL    = _testHost.ServiceUrl.ToString().Replace("[::]", "localhost"),
                MaxErrorRetry = 0
            };

            _lambdaClient = new AmazonLambdaClient(awsCredentials, lambdaConfig);
        }
Exemplo n.º 4
0
 private LambdaTestHost(LambdaTestHostSettings settings, IWebHost host, Uri serviceUrl)
 {
     _webHost   = host;
     Settings   = settings;
     ServiceUrl = serviceUrl;
 }