Skip to content

Commit 50491ff

Browse files
authored
Removing duplicate FUNCTIONS_WORKER_RUNTIME constant definition. (#11346)
* Removing duplicate FUNCTIONS_WORKER_RUNTIME constant definition. * Review updates
1 parent b7af455 commit 50491ff

32 files changed

+107
-119
lines changed

src/WebJobs.Script/Environment/EnvironmentExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
using System;
@@ -667,7 +667,7 @@ public static HashSet<string> GetLanguageWorkerListToStartInPlaceholder(this IEn
667667
{
668668
string placeholderList = environment.GetEnvironmentVariableOrDefault(RpcWorkerConstants.FunctionWorkerPlaceholderModeListSettingName, string.Empty);
669669
var placeholderRuntimeSet = new HashSet<string>(placeholderList.Trim().Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(p => p.Trim()));
670-
string workerRuntime = environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeSettingName);
670+
string workerRuntime = environment.GetEnvironmentVariable(FunctionWorkerRuntime);
671671

672672
if (!environment.IsInProc(workerRuntime))
673673
{
@@ -681,7 +681,7 @@ public static bool IsInProc(this IEnvironment environment, string workerRuntime
681681
{
682682
if (workerRuntime is null)
683683
{
684-
workerRuntime = environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeSettingName);
684+
workerRuntime = environment.GetEnvironmentVariable(FunctionWorkerRuntime);
685685
}
686686

687687
return string.IsNullOrEmpty(workerRuntime) || string.Equals(workerRuntime, RpcWorkerConstants.DotNetLanguageWorkerName, StringComparison.OrdinalIgnoreCase);

src/WebJobs.Script/FileProvisioning/FuncAppFileProvisioningService.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
using System.Threading;
55
using System.Threading.Tasks;
6-
using Microsoft.Azure.WebJobs.Script.Workers.Rpc;
76
using Microsoft.Extensions.Hosting;
87
using Microsoft.Extensions.Options;
98

@@ -29,7 +28,7 @@ public async Task StartAsync(CancellationToken cancellationToken)
2928
{
3029
if (!_options.CurrentValue.IsFileSystemReadOnly)
3130
{
32-
var funcAppFileProvisioner = _funcAppFileProvisionerFactory.CreatFileProvisioner(_environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeSettingName));
31+
var funcAppFileProvisioner = _funcAppFileProvisionerFactory.CreatFileProvisioner(_environment.GetEnvironmentVariable(EnvironmentSettingNames.FunctionWorkerRuntime));
3332
if (funcAppFileProvisioner != null)
3433
{
3534
await funcAppFileProvisioner.ProvisionFiles(_options.CurrentValue.ScriptPath);

src/WebJobs.Script/Host/WorkerFunctionMetadataProvider.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
using System;
55
using System.Collections.Generic;
66
using System.Collections.Immutable;
77
using System.IO.Abstractions;
88
using System.Linq;
9-
using System.Reactive.Linq;
109
using System.Threading.Tasks;
1110
using Microsoft.Azure.WebJobs.Script.Description;
1211
using Microsoft.Azure.WebJobs.Script.Diagnostics.Extensions;
@@ -232,7 +231,7 @@ internal IEnumerable<FunctionMetadata> ValidateMetadata(IEnumerable<RawFunctionM
232231
{
233232
Utility.ValidateName(function.Name);
234233

235-
function.Language = _environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeSettingName);
234+
function.Language = _environment.GetEnvironmentVariable(EnvironmentSettingNames.FunctionWorkerRuntime);
236235

237236
// skip function directory validation because this involves reading function.json
238237

src/WebJobs.Script/ScriptHostBuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ internal static ExtensionBundleOptions GetExtensionBundleOptions(IConfiguration
533533

534534
private static void RegisterFileProvisioningService(IHostBuilder builder)
535535
{
536-
if (string.Equals(Environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeSettingName), "powershell"))
536+
if (string.Equals(Environment.GetEnvironmentVariable(EnvironmentSettingNames.FunctionWorkerRuntime), "powershell"))
537537
{
538538
builder.ConfigureServices(services =>
539539
{

src/WebJobs.Script/Utility.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ internal static void VerifyFunctionsMatchSpecifiedLanguage(IEnumerable<FunctionM
642642
{
643643
if (string.IsNullOrEmpty(workerRuntime))
644644
{
645-
throw new HostInitializationException($"Found functions with more than one language. Select a language for your function app by specifying {RpcWorkerConstants.FunctionWorkerRuntimeSettingName} AppSetting");
645+
throw new HostInitializationException($"Found functions with more than one language. Select a language for your function app by specifying {EnvironmentSettingNames.FunctionWorkerRuntime} AppSetting");
646646
}
647647
else
648648
{

src/WebJobs.Script/Workers/ProcessManagement/DefaultWorkerProcessFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
using System;
@@ -100,7 +100,7 @@ internal string SanitizeExpandedArgument(string envExpandedString)
100100

101101
internal void ApplyWorkerConcurrencyLimits(ProcessStartInfo startInfo)
102102
{
103-
string functionWorkerRuntime = startInfo.EnvironmentVariables.GetValueOrNull(RpcWorkerConstants.FunctionWorkerRuntimeSettingName);
103+
string functionWorkerRuntime = startInfo.EnvironmentVariables.GetValueOrNull(EnvironmentSettingNames.FunctionWorkerRuntime);
104104
if (string.IsNullOrEmpty(startInfo.EnvironmentVariables.GetValueOrNull(RpcWorkerConstants.PythonThreadpoolThreadCount)) &&
105105
string.Equals(functionWorkerRuntime, RpcWorkerConstants.PythonLanguageWorkerName, StringComparison.OrdinalIgnoreCase))
106106
{

src/WebJobs.Script/Workers/Rpc/Configuration/LanguageWorkerOptionsSetup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public LanguageWorkerOptionsSetup(IConfiguration configuration,
4848

4949
public void Configure(LanguageWorkerOptions options)
5050
{
51-
string workerRuntime = _environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeSettingName);
51+
string workerRuntime = _environment.GetEnvironmentVariable(EnvironmentSettingNames.FunctionWorkerRuntime);
5252

5353
// Parsing worker.config.json should always be done in case of multi language worker
5454
if (!string.IsNullOrEmpty(workerRuntime) &&

src/WebJobs.Script/Workers/Rpc/Configuration/RpcWorkerConfigFactory.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public RpcWorkerConfigFactory(IConfiguration config,
4949
_environment = environment ?? throw new ArgumentNullException(nameof(environment));
5050
_metricsLogger = metricsLogger ?? throw new ArgumentNullException(nameof(metricsLogger));
5151
_profileManager = workerProfileManager ?? throw new ArgumentNullException(nameof(workerProfileManager));
52-
_workerRuntime = _environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeSettingName);
52+
_workerRuntime = _environment.GetEnvironmentVariable(EnvironmentSettingNames.FunctionWorkerRuntime);
5353
_workerConfigurationResolver = workerConfigurationResolver ?? throw new ArgumentNullException(nameof(workerConfigurationResolver));
5454
}
5555

@@ -321,14 +321,14 @@ internal bool ShouldAddWorkerConfig(string workerDescriptionLanguage)
321321

322322
if (!string.IsNullOrEmpty(_workerRuntime))
323323
{
324-
_logger.LogDebug("EnvironmentVariable {functionWorkerRuntimeSettingName}: {workerRuntime}", RpcWorkerConstants.FunctionWorkerRuntimeSettingName, _workerRuntime);
324+
_logger.LogDebug("EnvironmentVariable {functionWorkerRuntimeSettingName}: {workerRuntime}", EnvironmentSettingNames.FunctionWorkerRuntime, _workerRuntime);
325325
if (_workerRuntime.Equals(workerDescriptionLanguage, StringComparison.OrdinalIgnoreCase))
326326
{
327327
return true;
328328
}
329329

330330
// After specialization only create worker provider for the language set by FUNCTIONS_WORKER_RUNTIME env variable
331-
_logger.LogInformation("{FUNCTIONS_WORKER_RUNTIME} set to {workerRuntime}. Skipping WorkerConfig for language: {workerDescriptionLanguage}", RpcWorkerConstants.FunctionWorkerRuntimeSettingName, _workerRuntime, workerDescriptionLanguage);
331+
_logger.LogInformation("{FUNCTIONS_WORKER_RUNTIME} set to {workerRuntime}. Skipping WorkerConfig for language: {workerDescriptionLanguage}", EnvironmentSettingNames.FunctionWorkerRuntime, _workerRuntime, workerDescriptionLanguage);
332332
return false;
333333
}
334334

src/WebJobs.Script/Workers/Rpc/FunctionRegistration/RpcFunctionInvocationDispatcher.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public RpcFunctionInvocationDispatcher(IOptions<ScriptJobHostOptions> scriptHost
9595
_managedDependencyOptions = managedDependencyOptions ?? throw new ArgumentNullException(nameof(managedDependencyOptions));
9696
_logger = loggerFactory.CreateLogger<RpcFunctionInvocationDispatcher>();
9797
_rpcWorkerChannelFactory = rpcWorkerChannelFactory;
98-
_workerRuntime = _environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeSettingName);
98+
_workerRuntime = _environment.GetEnvironmentVariable(EnvironmentSettingNames.FunctionWorkerRuntime);
9999
_functionDispatcherLoadBalancer = functionDispatcherLoadBalancer;
100100
_workerConcurrencyOptions = workerConcurrencyOptions;
101101
_hostingConfigOptions = hostingConfigOptions;
@@ -198,7 +198,7 @@ internal async Task InitializeWebhostLanguageWorkerChannel(IEnumerable<string> l
198198

199199
internal async void ShutdownWebhostLanguageWorkerChannels()
200200
{
201-
_logger.LogDebug("{workerRuntimeConstant}={value}. Will shutdown all the worker channels that started in placeholder mode", RpcWorkerConstants.FunctionWorkerRuntimeSettingName, _workerRuntime);
201+
_logger.LogDebug("{workerRuntimeConstant}={value}. Will shutdown all the worker channels that started in placeholder mode", EnvironmentSettingNames.FunctionWorkerRuntime, _workerRuntime);
202202
await _webHostLanguageWorkerChannelManager?.ShutdownChannelsAsync();
203203
}
204204

src/WebJobs.Script/Workers/Rpc/RpcInitializationService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
using System;
@@ -33,7 +33,7 @@ public RpcInitializationService(IOptionsMonitor<ScriptApplicationHostOptions> ap
3333
_environment = environment;
3434
_rpcServerShutdownTimeoutInMilliseconds = 5000;
3535
_webHostRpcWorkerChannelManager = rpcWorkerChannelManager ?? throw new ArgumentNullException(nameof(rpcWorkerChannelManager));
36-
_workerRuntime = _environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeSettingName);
36+
_workerRuntime = _environment.GetEnvironmentVariable(EnvironmentSettingNames.FunctionWorkerRuntime);
3737
_placeholderLanguageWorkersList = _environment.GetLanguageWorkerListToStartInPlaceholder();
3838
_languageWorkerOptions = languageWorkerOptions;
3939
}
@@ -116,7 +116,7 @@ internal Task InitializeChannelsAsync()
116116

117117
if (_environment.IsPlaceholderModeEnabled())
118118
{
119-
_logger.LogDebug("Initializing language worker channels. {workerRuntimeSetting}: '{workerRuntime}', placeholderChannelList: '{placeholderChannelList}' in placeholder mode.", nameof(RpcWorkerConstants.FunctionWorkerRuntimeSettingName), _workerRuntime, string.Join(",", _placeholderLanguageWorkersList));
119+
_logger.LogDebug("Initializing language worker channels. {workerRuntimeSetting}: '{workerRuntime}', placeholderChannelList: '{placeholderChannelList}' in placeholder mode.", nameof(EnvironmentSettingNames.FunctionWorkerRuntime), _workerRuntime, string.Join(",", _placeholderLanguageWorkersList));
120120

121121
if (_placeholderLanguageWorkersList.Count() != 0)
122122
{

0 commit comments

Comments
 (0)