コード例 #1
0
        internal void FormatWorkerPathIfNeeded(ISystemRuntimeInformation systemRuntimeInformation, IEnvironment environment, ILogger logger)
        {
            if (string.IsNullOrEmpty(DefaultWorkerPath))
            {
                return;
            }

            OSPlatform   os            = systemRuntimeInformation.GetOSPlatform();
            Architecture architecture  = systemRuntimeInformation.GetOSArchitecture();
            string       workerRuntime = environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeSettingName);
            string       version       = environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeVersionSettingName);

            logger.LogDebug($"EnvironmentVariable {RpcWorkerConstants.FunctionWorkerRuntimeVersionSettingName}: {version}");

            // Only over-write DefaultRuntimeVersion if workerRuntime matches language for the worker config
            if (!string.IsNullOrEmpty(workerRuntime) && workerRuntime.Equals(Language, StringComparison.OrdinalIgnoreCase) && !string.IsNullOrEmpty(version))
            {
                DefaultRuntimeVersion = GetSanitizedRuntimeVersion(version);
            }

            ValidateDefaultWorkerPathFormatters(systemRuntimeInformation);

            DefaultWorkerPath = DefaultWorkerPath.Replace(RpcWorkerConstants.OSPlaceholder, os.ToString())
                                .Replace(RpcWorkerConstants.ArchitecturePlaceholder, architecture.ToString())
                                .Replace(RpcWorkerConstants.RuntimeVersionPlaceholder, DefaultRuntimeVersion);
        }
コード例 #2
0
        public WorkerConfigFactory(IConfiguration config, ILogger logger, ISystemRuntimeInformation systemRuntimeInfo, IEnvironment environment)
        {
            _config = config ?? throw new ArgumentNullException(nameof(config));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));
            _systemRuntimeInformation = systemRuntimeInfo ?? throw new ArgumentNullException(nameof(systemRuntimeInfo));
            _environment   = environment ?? throw new ArgumentNullException(nameof(environment));
            WorkersDirPath = Path.Combine(Path.GetDirectoryName(new Uri(typeof(WorkerConfigFactory).Assembly.CodeBase).LocalPath), LanguageWorkerConstants.DefaultWorkersDirectoryName);
            var workersDirectorySection = _config.GetSection($"{LanguageWorkerConstants.LanguageWorkersSectionName}:{OutOfProcConstants.WorkersDirectorySectionName}");

            if (!string.IsNullOrEmpty(workersDirectorySection.Value))
            {
                WorkersDirPath = workersDirectorySection.Value;
            }
        }
コード例 #3
0
        public RpcWorkerConfigFactory(IConfiguration config, ILogger logger, ISystemRuntimeInformation systemRuntimeInfo, IEnvironment environment, IMetricsLogger metricsLogger)
        {
            _config = config ?? throw new ArgumentNullException(nameof(config));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));
            _systemRuntimeInformation = systemRuntimeInfo ?? throw new ArgumentNullException(nameof(systemRuntimeInfo));
            _environment   = environment ?? throw new ArgumentNullException(nameof(environment));
            _metricsLogger = metricsLogger;
            string assemblyLocalPath = Path.GetDirectoryName(new Uri(typeof(RpcWorkerConfigFactory).Assembly.CodeBase).LocalPath);

            WorkersDirPath = GetDefaultWorkersDirectory(Directory.Exists);
            var workersDirectorySection = _config.GetSection($"{RpcWorkerConstants.LanguageWorkersSectionName}:{WorkerConstants.WorkersDirectorySectionName}");

            if (!string.IsNullOrEmpty(workersDirectorySection.Value))
            {
                WorkersDirPath = workersDirectorySection.Value;
            }
        }
コード例 #4
0
        internal void ValidateDefaultWorkerPathFormatters(ISystemRuntimeInformation systemRuntimeInformation)
        {
            if (DefaultWorkerPath.Contains(RpcWorkerConstants.OSPlaceholder))
            {
                ValidateOSPlatform(systemRuntimeInformation.GetOSPlatform());
            }

            if (DefaultWorkerPath.Contains(RpcWorkerConstants.ArchitecturePlaceholder))
            {
                ValidateArchitecture(systemRuntimeInformation.GetOSArchitecture());
            }

            if (DefaultWorkerPath.Contains(RpcWorkerConstants.RuntimeVersionPlaceholder) && !string.IsNullOrEmpty(DefaultRuntimeVersion))
            {
                ValidateRuntimeVersion();
            }
        }
コード例 #5
0
        internal void FormatWorkerPathIfNeeded(ISystemRuntimeInformation systemRuntimeInformation, IEnvironment environment, ILogger logger)
        {
            if (string.IsNullOrEmpty(DefaultWorkerPath))
            {
                return;
            }

            OSPlatform   os           = systemRuntimeInformation.GetOSPlatform();
            Architecture architecture = systemRuntimeInformation.GetOSArchitecture();
            string       version      = environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeVersionSettingName);

            logger.LogDebug($"EnvironmentVariable {RpcWorkerConstants.FunctionWorkerRuntimeVersionSettingName}: {version}");

            if (!string.IsNullOrEmpty(version))
            {
                DefaultRuntimeVersion = version;
            }

            ValidateDefaultWorkerPathFormatters(systemRuntimeInformation);

            DefaultWorkerPath = DefaultWorkerPath.Replace(RpcWorkerConstants.OSPlaceholder, os.ToString())
                                .Replace(RpcWorkerConstants.ArchitecturePlaceholder, architecture.ToString())
                                .Replace(RpcWorkerConstants.RuntimeVersionPlaceholder, DefaultRuntimeVersion);
        }