示例#1
0
        internal IEnumerable <FunctionMetadata> GetFunctionsMetadata(ScriptJobHostOptions hostOptions, ILogger logger, bool includeProxies = false)
        {
            IEnumerable <FunctionMetadata> functionsMetadata = _functionMetadataProvider.GetFunctionMetadata();

            if (includeProxies)
            {
                // get proxies metadata
                var values = ProxyMetadataManager.ReadProxyMetadata(hostOptions.RootScriptPath, logger);
                var proxyFunctionsMetadata = values.Item1;
                if (proxyFunctionsMetadata?.Count > 0)
                {
                    functionsMetadata = proxyFunctionsMetadata.Concat(functionsMetadata);
                }
            }

            return(functionsMetadata);
        }
示例#2
0
        internal static IEnumerable <FunctionMetadata> GetFunctionsMetadata(ScriptJobHostOptions hostOptions, IEnumerable <WorkerConfig> workerConfigs, ILogger logger, bool includeProxies = false)
        {
            var functionDirectories = FileUtility.EnumerateDirectories(hostOptions.RootScriptPath);
            IEnumerable <FunctionMetadata> functionsMetadata = FunctionMetadataManager.ReadFunctionsMetadata(functionDirectories, null, workerConfigs, logger, fileSystem: FileUtility.Instance);

            if (includeProxies)
            {
                // get proxies metadata
                var values = ProxyMetadataManager.ReadProxyMetadata(hostOptions.RootScriptPath, logger);
                var proxyFunctionsMetadata = values.Item1;
                if (proxyFunctionsMetadata?.Count > 0)
                {
                    functionsMetadata = proxyFunctionsMetadata.Concat(functionsMetadata);
                }
            }

            return(functionsMetadata);
        }
示例#3
0
        internal IEnumerable <FunctionMetadata> GetFunctionsMetadata(bool includeProxies = false)
        {
            var hostOptions         = _applicationHostOptions.CurrentValue.ToHostOptions();
            var functionDirectories = FileUtility.EnumerateDirectories(hostOptions.RootScriptPath);
            IEnumerable <FunctionMetadata> functionsMetadata = FunctionMetadataManager.ReadFunctionsMetadata(functionDirectories, null, _workerConfigs, _logger, fileSystem: FileUtility.Instance);

            if (includeProxies)
            {
                // get proxies metadata
                var values = ProxyMetadataManager.ReadProxyMetadata(hostOptions.RootScriptPath, _logger);
                var proxyFunctionsMetadata = values.Item1;
                if (proxyFunctionsMetadata?.Count > 0)
                {
                    functionsMetadata = proxyFunctionsMetadata.Concat(functionsMetadata);
                }
            }

            return(functionsMetadata);
        }
示例#4
0
        public void ProxyMetadata_WhenProxyFileChanges_IsRefreshed()
        {
            using (var tempDirectory = new TempDirectory())
            {
                var testProxiesPath = Path.Combine(Environment.CurrentDirectory, @"TestScripts\Proxies");
                var options         = new OptionsWrapper <ScriptJobHostOptions>(new ScriptJobHostOptions
                {
                    RootScriptPath = tempDirectory.Path
                });

                var environment  = new TestEnvironment();
                var eventManager = new ScriptEventManager();

                var manager = new ProxyMetadataManager(options, environment, eventManager, NullLoggerFactory.Instance);

                // Get metadata before proxies exist
                ProxyMetadataInfo proxyMetadata1 = manager.ProxyMetadata;
                ProxyMetadataInfo proxyMetadata2 = manager.ProxyMetadata;

                Assert.True(proxyMetadata2.Functions.IsDefaultOrEmpty);
                Assert.Same(proxyMetadata1, proxyMetadata2);

                // Update our proxies definition
                FileUtility.CopyDirectory(testProxiesPath, tempDirectory.Path);

                // Simulate a file change notification
                eventManager.Publish(new FileEvent(EventSources.ScriptFiles,
                                                   new FileSystemEventArgs(WatcherChangeTypes.Changed, tempDirectory.Path, ScriptConstants.ProxyMetadataFileName)));

                ProxyMetadataInfo proxyMetadata3 = manager.ProxyMetadata;

                Assert.NotSame(proxyMetadata1, proxyMetadata3);

                Assert.Equal(19, proxyMetadata3.Functions.Length);
            }
        }
示例#5
0
 public void UpdateProxyName(string proxyName)
 {
     Assert.Equal("myproxy", ProxyMetadataManager.NormalizeProxyName(proxyName));
 }