Exemplo n.º 1
0
        public static ILocalLambdaRuntime Initialize(string directory, IAWSService awsService)
        {
            if (!Directory.Exists(directory))
            {
                throw new DirectoryNotFoundException($"Directory containing built Lambda project does not exist {directory}");
            }

            var depsFile = Directory.GetFiles(directory, "*.deps.json").FirstOrDefault();

            if (depsFile == null)
            {
                throw new Exception($"Failed to find a deps.json file in the specified directory ({directory})");
            }

            var fileName = depsFile.Substring(0, depsFile.Length - ".deps.json".Length) + ".dll";

            if (!File.Exists(fileName))
            {
                throw new Exception($"Failed to find Lambda project entry assembly in the specified directory ({directory})");
            }

            // The resolver provides the ability to load the assemblies containing the select Lambda function.
            var resolver = new LambdaAssemblyLoadContext(fileName);

            var runtime = new LocalLambdaRuntime(resolver, directory, awsService);

            return(runtime);
        }
Exemplo n.º 2
0
 private LocalLambdaRuntime(LambdaAssemblyLoadContext lambdaContext, string lambdaAssemblyDirectory, IAWSService awsService)
 {
     LambdaContext = lambdaContext;
     this.LambdaAssemblyDirectory = lambdaAssemblyDirectory;
     this.AWSService = awsService;
 }