public Task InvokeAsync(HttpContext context, string functionName)
        {
            if (_isWarmup)
            {
                // warmup function will get executed just once for the process.
                if (Interlocked.CompareExchange(ref _warmupExecuted, 1, 0) != 0)
                {
                    return(Task.CompletedTask);
                }
            }

            var descriptor = _functionMap.GetOrAdd(functionName, (name) =>
            {
                return(_scriptHost.Functions.FirstOrDefault(p => string.Equals(p.Name, name, StringComparison.OrdinalIgnoreCase)));
            });

            if (_isWarmup && descriptor == null)
            {
                // TODO: further optimization, If there is no warmup trigger provided we should call a simple warmup function for the given language of the function app.
                return(Task.CompletedTask);
            }

            var executionFeature = new FunctionExecutionFeature(_scriptHost, descriptor, _environment, _loggerFactory);

            context.Features.Set <IFunctionExecutionFeature>(executionFeature);

            return(Task.CompletedTask);
        }
        public async Task InvokeAsync(HttpContext context, string functionName)
        {
            // TODO: FACAVAL This should be improved....
            var host             = _scriptHostManager.Instance;
            var descriptor       = host.Functions.FirstOrDefault(f => string.Equals(f.Name, functionName));
            var executionFeature = new FunctionExecutionFeature(host, descriptor, _settingsManager, _loggerFactory);

            context.Features.Set <IFunctionExecutionFeature>(executionFeature);

            await Task.CompletedTask;
        }
Exemple #3
0
        public async Task InvokeAsync(HttpContext context, string functionName)
        {
            if (_isProxy)
            {
                ProxyFunctionExecutor proxyFunctionExecutor = new ProxyFunctionExecutor(_scriptHost);
                context.Items.TryAdd(ScriptConstants.AzureProxyFunctionExecutorKey, proxyFunctionExecutor);
            }

            var descriptor       = _scriptHost.Functions.FirstOrDefault(f => string.Equals(f.Name, functionName));
            var executionFeature = new FunctionExecutionFeature(_scriptHost, descriptor, _environment, _loggerFactory);

            context.Features.Set <IFunctionExecutionFeature>(executionFeature);

            await Task.CompletedTask;
        }