示例#1
0
 public WorkerConcurrencyManager(
     IFunctionInvocationDispatcherFactory functionInvocationDispatcherFactory,
     IEnvironment environment,
     IOptions <WorkerConcurrencyOptions> workerConcurrencyOptions,
     IFunctionsHostingConfiguration functionsHostingConfigurations,
     IApplicationLifetime applicationLifetime,
     ILoggerFactory loggerFactory)
 {
     _functionInvocationDispatcherFactory = functionInvocationDispatcherFactory ?? throw new ArgumentNullException(nameof(functionInvocationDispatcherFactory));
     _environment = environment ?? throw new ArgumentNullException(nameof(environment));
     _workerConcurrencyOptions       = workerConcurrencyOptions;
     _functionsHostingConfigurations = functionsHostingConfigurations;
     _applicationLifetime            = applicationLifetime;
     _logger = loggerFactory?.CreateLogger(LogCategories.Concurrency);
 }
示例#2
0
        public WorkerConcurrencyManagerTest()
        {
            _loggerProvider = new TestLoggerProvider();
            _loggerFactory  = new LoggerFactory();
            _loggerFactory.AddProvider(_loggerProvider);
            _testEnvironment = new TestEnvironment();
            _testEnvironment.SetEnvironmentVariable(RpcWorkerConstants.FunctionsWorkerDynamicConcurrencyEnabled, "true");
            _testEnvironment.SetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeSettingName, RpcWorkerConstants.PythonLanguageWorkerName);
            _testEnvironment.SetEnvironmentVariable(EnvironmentSettingNames.FunctionWorkerRuntime, RpcWorkerConstants.NodeLanguageWorkerName);
            Mock <IFunctionsHostingConfiguration> conf = new Mock <IFunctionsHostingConfiguration>();

            conf.Setup(x => x.FunctionsWorkerDynamicConcurrencyEnabled).Returns(false);
            _functionsHostingConfigurations = conf.Object;
            Mock <IApplicationLifetime> applicationLifetime = new Mock <IApplicationLifetime>();

            applicationLifetime.Setup(x => x.StopApplication()).Verifiable();
            _applicationLifetime = applicationLifetime.Object;
        }