public WorkerFunctionDescriptorProvider(ScriptHost host, ScriptJobHostOptions config, ICollection <IScriptBindingProvider> bindingProviders, IFunctionDispatcher dispatcher, ILoggerFactory loggerFactory) : base(host, config, bindingProviders) { _dispatcher = dispatcher; _loggerFactory = loggerFactory; }
private async Task WaitForFunctionDispactherStateInitialized(IFunctionDispatcher functionDispatcher) { await TestHelpers.Await(() => { return(functionDispatcher.State == FunctionDispatcherState.Initialized); }, pollingInterval : 4 * 1000, timeout : 60 * 1000); }
public void IsSupported_Returns_False(string language, string funcMetadataLanguage) { IFunctionDispatcher functionDispatcher = GetTestFunctionDispatcher(); FunctionMetadata func1 = new FunctionMetadata() { Name = "func1", Language = funcMetadataLanguage }; Assert.False(functionDispatcher.IsSupported(func1, language)); }
private async Task <int> WaitForJobhostWorkerChannelsToStartup(IFunctionDispatcher functionDispatcher, int expectedCount) { int currentChannelCount = 0; await TestHelpers.Await(() => { currentChannelCount = functionDispatcher.WorkerState.GetChannels().Count(); return(currentChannelCount == expectedCount); }, pollingInterval : 5 * 1000, timeout : 60 * 1000); return(currentChannelCount); }
internal static void AddLanguageWorkerChannelErrors(IFunctionDispatcher functionDispatcher, IDictionary <string, ICollection <string> > functionErrors) { foreach (KeyValuePair <WorkerConfig, LanguageWorkerState> kvp in functionDispatcher.LanguageWorkerChannelStates) { WorkerConfig workerConfig = kvp.Key; LanguageWorkerState workerState = kvp.Value; foreach (var functionRegistrationContext in workerState.GetRegistrations()) { var exMessage = $"Failed to start language worker process for: {workerConfig.Language}"; var languageWorkerChannelException = workerState.Errors != null && workerState.Errors.Count > 0 ? new LanguageWorkerChannelException(exMessage, workerState.Errors[workerState.Errors.Count - 1]) : new LanguageWorkerChannelException(exMessage); Utility.AddFunctionError(functionErrors, functionRegistrationContext.Metadata.Name, Utility.FlattenException(languageWorkerChannelException, includeSource: false)); } } }
private async Task InitializeWorkersAsync() { var serverImpl = new FunctionRpcService(EventManager, _logger); var server = new GrpcServer(serverImpl, ScriptOptions.MaxMessageLengthBytes); using (_metricsLogger.LatencyEvent(MetricEventNames.HostStartupGrpcServerLatency)) { await server.StartAsync(); } var processFactory = new DefaultWorkerProcessFactory(); try { _processRegistry = ProcessRegistryFactory.Create(); } catch (Exception e) { _logger.LogWarning(e, "Unable to create process registry"); } CreateChannel channelFactory = (languageWorkerConfig, registrations, attemptCount) => { return(new LanguageWorkerChannel( ScriptOptions, EventManager, processFactory, _processRegistry, registrations, languageWorkerConfig, server.Uri, _loggerFactory, // TODO: DI (FACAVAL) Pass appropriate logger. Channel facory should likely be a service. _metricsLogger, attemptCount)); }; _functionDispatcher = new FunctionDispatcher(EventManager, server, channelFactory, _workerConfigs, _language); _eventSubscriptions.Add(EventManager.OfType <WorkerProcessErrorEvent>() .Subscribe(evt => { HandleHostError(evt.Exception); })); }
internal WorkerLanguageInvoker(ScriptHost host, BindingMetadata bindingMetadata, FunctionMetadata functionMetadata, ILoggerFactory loggerFactory, Collection <FunctionBinding> inputBindings, Collection <FunctionBinding> outputBindings, IFunctionDispatcher fuctionDispatcher) : base(host, functionMetadata, loggerFactory) { _bindingMetadata = bindingMetadata; _inputBindings = inputBindings; _outputBindings = outputBindings; _functionDispatcher = fuctionDispatcher; _logger = loggerFactory.CreateLogger <WorkerLanguageInvoker>(); InitializeFileWatcherIfEnabled(); if (_outputBindings.Any(p => p.Metadata.IsReturn)) { _handleScriptReturnValue = HandleReturnParameter; } else { _handleScriptReturnValue = HandleOutputDictionary; } }
public RpcInitializationService(IRpcServer rpcServer, IFunctionDispatcher functionDispatcher, IScriptEventManager eventManager) { _rpcServer = rpcServer; _eventManager = eventManager; _functionDispatcher = functionDispatcher; }
// Specify the "builtin binding types". These are types that are directly accesible without needing an explicit load gesture. // This is the set of bindings we shipped prior to binding extensibility. // Map from BindingType to the Assembly Qualified Type name for its IExtensionConfigProvider object. public ScriptHost(IOptions <JobHostOptions> options, IOptions <LanguageWorkerOptions> languageWorkerOptions, IEnvironment environment, IJobHostContextFactory jobHostContextFactory, IConfiguration configuration, IDistributedLockManager distributedLockManager, IScriptHostManager scriptHostManager, IScriptEventManager eventManager, ILoggerFactory loggerFactory, IFunctionDispatcher functionDispatcher, IFunctionMetadataManager functionMetadataManager, IProxyMetadataManager proxyMetadataManager, IMetricsLogger metricsLogger, IOptions <ScriptJobHostOptions> scriptHostOptions, ITypeLocator typeLocator, IScriptJobHostEnvironment scriptHostEnvironment, IDebugStateProvider debugManager, IEnumerable <IScriptBindingProvider> bindingProviders, IPrimaryHostStateProvider primaryHostStateProvider, IJobHostMetadataProvider metadataProvider, IHostIdProvider hostIdProvider, ScriptSettingsManager settingsManager = null) : base(options, jobHostContextFactory) { _environment = environment; _typeLocator = typeLocator as ScriptTypeLocator ?? throw new ArgumentException(nameof(typeLocator), $"A {nameof(ScriptTypeLocator)} instance is required."); _instanceId = Guid.NewGuid().ToString(); _hostOptions = options; _configuration = configuration; _storageConnectionString = configuration.GetWebJobsConnectionString(ConnectionStringNames.Storage); _distributedLockManager = distributedLockManager; _functionMetadataManager = functionMetadataManager; _hostIdProvider = hostIdProvider; _proxyMetadataManager = proxyMetadataManager; _workerConfigs = languageWorkerOptions.Value.WorkerConfigs; ScriptOptions = scriptHostOptions.Value; _scriptHostEnvironment = scriptHostEnvironment; FunctionErrors = new Dictionary <string, ICollection <string> >(StringComparer.OrdinalIgnoreCase); EventManager = eventManager; _functionDispatcher = functionDispatcher; _settingsManager = settingsManager ?? ScriptSettingsManager.Instance; _metricsLogger = metricsLogger; _hostLogPath = Path.Combine(ScriptOptions.RootLogPath, "Host"); _workerRuntime = _environment.GetEnvironmentVariable(LanguageWorkerConstants.FunctionWorkerRuntimeSettingName); _loggerFactory = loggerFactory; _logger = loggerFactory.CreateLogger(LogCategories.Startup); Logger = _logger; _debugManager = debugManager; _primaryHostStateProvider = primaryHostStateProvider; _bindingProviders = new List <IScriptBindingProvider>(bindingProviders); _metadataProvider = metadataProvider; _eventSubscriptions.Add(EventManager.OfType <FunctionIndexingEvent>() .Subscribe(evt => { HandleHostError(evt.Exception); })); }
public InvocationsController(IFunctionDispatcher functionDispatcher) { _functionDispatcher = functionDispatcher; }
public RpcFunctionDescriptorProvider(ScriptHost host, string workerRuntime, ScriptJobHostOptions config, ICollection <IScriptBindingProvider> bindingProviders, IFunctionDispatcher dispatcher, ILoggerFactory loggerFactory) : base(host, config, bindingProviders, dispatcher, loggerFactory) { _workerRuntime = workerRuntime; }
public HttpFunctionDescriptorProvider(ScriptHost host, ScriptJobHostOptions config, ICollection <IScriptBindingProvider> bindingProviders, IFunctionDispatcher dispatcher, ILoggerFactory loggerFactory) : base(host, config, bindingProviders, dispatcher, loggerFactory) { }