예제 #1
0
        internal async Task <IRpcWorkerChannel> InitializeLanguageWorkerChannel(string runtime, string scriptRootPath)
        {
            IRpcWorkerChannel rpcWorkerChannel = null;
            string            workerId         = Guid.NewGuid().ToString();

            _logger.LogDebug("Creating language worker channel for runtime:{runtime}", runtime);
            try
            {
                rpcWorkerChannel = _rpcWorkerChannelFactory.Create(scriptRootPath, runtime, _metricsLogger, 0, _lanuageworkerOptions.CurrentValue.WorkerConfigs);
                AddOrUpdateWorkerChannels(runtime, rpcWorkerChannel);
                await rpcWorkerChannel.StartWorkerProcessAsync().ContinueWith(processStartTask =>
                {
                    if (processStartTask.Status == TaskStatus.RanToCompletion)
                    {
                        _logger.LogDebug("Adding jobhost language worker channel for runtime: {language}. workerId:{id}", _workerRuntime, rpcWorkerChannel.Id);
                        SetInitializedWorkerChannel(runtime, rpcWorkerChannel);
                    }
                    else if (processStartTask.Status == TaskStatus.Faulted)
                    {
                        _logger.LogError("Failed to start language worker process for runtime: {language}. workerId:{id}", _workerRuntime, rpcWorkerChannel.Id);
                        SetExceptionOnInitializedWorkerChannel(runtime, rpcWorkerChannel, processStartTask.Exception);
                    }
                });
            }
            catch (Exception ex)
            {
                throw new HostInitializationException($"Failed to start Language Worker Channel for language :{runtime}", ex);
            }
            return(rpcWorkerChannel);
        }
        public async Task <IRpcWorkerChannel> InitializeChannelAsync(string language)
        {
            var metricsLogger = new Mock <IMetricsLogger>();
            IRpcWorkerChannel workerChannel = _testLanguageWorkerChannelFactory.Create(_scriptRootPath, language, metricsLogger.Object, 0);

            if (_workerChannels.TryGetValue(language, out Dictionary <string, TaskCompletionSource <IRpcWorkerChannel> > workerChannels))
            {
                workerChannels.Add(workerChannel.Id, new TaskCompletionSource <IRpcWorkerChannel>());
            }
            else
            {
                _workerChannels.TryAdd(language, new Dictionary <string, TaskCompletionSource <IRpcWorkerChannel> >());
                _workerChannels[language].Add(workerChannel.Id, new TaskCompletionSource <IRpcWorkerChannel>());
            }

            await workerChannel.StartWorkerProcessAsync().ContinueWith(processStartTask =>
            {
                if (processStartTask.Status == TaskStatus.RanToCompletion)
                {
                    SetInitializedWorkerChannel(language, workerChannel);
                }
                else if (processStartTask.Status == TaskStatus.Faulted)
                {
                    SetExceptionOnInitializedWorkerChannel(language, workerChannel, processStartTask.Exception);
                }
            });

            return(workerChannel);
        }
        private IRpcWorkerChannel CreateTestChannel(string language)
        {
            var testChannel = _rpcWorkerChannelFactory.Create(_scriptRootPath, language, null, 0);

            _rpcWorkerChannelManager.AddOrUpdateWorkerChannels(language, testChannel);
            _rpcWorkerChannelManager.SetInitializedWorkerChannel(language, testChannel);
            return(testChannel);
        }
        private IRpcWorkerChannel CreateTestChannel(string language)
        {
            var testChannel = _rpcWorkerChannelFactory.Create(_scriptRootPath, language, null, 0, _workerOptionsMonitor.CurrentValue.WorkerConfigs);

            _rpcWorkerChannelManager.AddOrUpdateWorkerChannels(language, testChannel);
            _rpcWorkerChannelManager.SetInitializedWorkerChannel(language, testChannel);
            return(testChannel);
        }
예제 #5
0
        internal async Task InitializeJobhostLanguageWorkerChannelAsync(int attemptCount)
        {
            var rpcWorkerChannel = _rpcWorkerChannelFactory.Create(_scriptOptions.RootScriptPath, _workerRuntime, _metricsLogger, attemptCount, _workerConfigs);

            rpcWorkerChannel.SetupFunctionInvocationBuffers(_functions);
            _jobHostLanguageWorkerChannelManager.AddChannel(rpcWorkerChannel);
            await rpcWorkerChannel.StartWorkerProcessAsync();

            _logger.LogDebug("Adding jobhost language worker channel for runtime: {language}. workerId:{id}", _workerRuntime, rpcWorkerChannel.Id);
            rpcWorkerChannel.SendFunctionLoadRequests(_managedDependencyOptions.Value, _scriptOptions.FunctionTimeout);
            SetFunctionDispatcherStateToInitializedAndLog();
        }
예제 #6
0
        internal Task InitializeJobhostLanguageWorkerChannelAsync(int attemptCount)
        {
            var rpcWorkerChannel = _rpcWorkerChannelFactory.Create(_scriptOptions.RootScriptPath, _workerRuntime, _metricsLogger, attemptCount, _workerConfigs);

            rpcWorkerChannel.SetupFunctionInvocationBuffers(_functions);
            _jobHostLanguageWorkerChannelManager.AddChannel(rpcWorkerChannel);
            rpcWorkerChannel.StartWorkerProcessAsync().ContinueWith(workerInitTask =>
            {
                _logger.LogDebug("Adding jobhost language worker channel for runtime: {language}. workerId:{id}", _workerRuntime, rpcWorkerChannel.Id);
                rpcWorkerChannel.SendFunctionLoadRequests(_managedDependencyOptions.Value);
                SetFunctionDispatcherStateToInitializedAndLog();
            }, TaskContinuationOptions.OnlyOnRanToCompletion);
            return(Task.CompletedTask);
        }
예제 #7
0
        internal Task InitializeJobhostLanguageWorkerChannelAsync(int attemptCount)
        {
            var rpcWorkerChannel = _rpcWorkerChannelFactory.Create(_scriptOptions.RootScriptPath, _workerRuntime, _metricsLogger, attemptCount);

            rpcWorkerChannel.SetupFunctionInvocationBuffers(_functions);
            _jobHostLanguageWorkerChannelManager.AddChannel(rpcWorkerChannel);
            rpcWorkerChannel.StartWorkerProcessAsync().ContinueWith(workerInitTask =>
            {
                if (workerInitTask.IsCompleted)
                {
                    _logger.LogDebug("Adding jobhost language worker channel for runtime: {language}. workerId:{id}", _workerRuntime, rpcWorkerChannel.Id);
                    rpcWorkerChannel.SendFunctionLoadRequests(_managedDependencyOptions.Value);
                    State = FunctionInvocationDispatcherState.Initialized;
                }
                else
                {
                    _logger.LogWarning("Failed to start language worker process for runtime: {language}. workerId:{id}", _workerRuntime, rpcWorkerChannel.Id);
                }
            });
            return(Task.CompletedTask);
        }