Skip to content

Commit 38e81b7

Browse files
authored
Do not use cached options to create worker process (#5990)
1 parent 3ea6d9d commit 38e81b7

File tree

4 files changed

+4
-12
lines changed

4 files changed

+4
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ namespace Microsoft.Azure.WebJobs.Script.Workers.Rpc
55
{
66
public interface IRpcWorkerProcessFactory
77
{
8-
IWorkerProcess Create(string workerId, string runtime, string scriptRootPath);
8+
IWorkerProcess Create(string workerId, string runtime, string scriptRootPath, RpcWorkerConfig rpcWorkerConfig);
99
}
1010
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public IRpcWorkerChannel Create(string scriptRootPath, string runtime, IMetricsL
4040
}
4141
string workerId = Guid.NewGuid().ToString();
4242
ILogger workerLogger = _loggerFactory.CreateLogger($"Worker.LanguageWorkerChannel.{runtime}.{workerId}");
43-
IWorkerProcess rpcWorkerProcess = _rpcWorkerProcessFactory.Create(workerId, runtime, scriptRootPath);
43+
IWorkerProcess rpcWorkerProcess = _rpcWorkerProcessFactory.Create(workerId, runtime, scriptRootPath, languageWorkerConfig);
4444
return new RpcWorkerChannel(
4545
workerId,
4646
_eventManager,

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

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

4-
using System;
5-
using System.Collections.Generic;
6-
using System.Linq;
74
using Microsoft.Azure.WebJobs.Script.Abstractions;
85
using Microsoft.Azure.WebJobs.Script.Eventing;
96
using Microsoft.Extensions.Logging;
10-
using Microsoft.Extensions.Options;
117

128
namespace Microsoft.Azure.WebJobs.Script.Workers.Rpc
139
{
1410
internal class RpcWorkerProcessFactory : IRpcWorkerProcessFactory
1511
{
1612
private readonly IWorkerProcessFactory _workerProcessFactory;
17-
private readonly IEnumerable<RpcWorkerConfig> _workerConfigs = null;
1813
private readonly IProcessRegistry _processRegistry;
1914
private readonly ILoggerFactory _loggerFactory = null;
2015
private readonly IScriptEventManager _eventManager = null;
2116
private readonly IRpcServer _rpcServer = null;
2217
private readonly IWorkerConsoleLogSource _consoleLogSource;
2318

2419
public RpcWorkerProcessFactory(IRpcServer rpcServer,
25-
IOptions<LanguageWorkerOptions> languageWorkerOptions,
2620
IScriptEventManager eventManager,
2721
ILoggerFactory loggerFactory,
2822
IWorkerProcessFactory defaultWorkerProcessFactory,
@@ -32,15 +26,13 @@ public RpcWorkerProcessFactory(IRpcServer rpcServer,
3226
_loggerFactory = loggerFactory;
3327
_eventManager = eventManager;
3428
_rpcServer = rpcServer;
35-
_workerConfigs = languageWorkerOptions.Value.WorkerConfigs;
3629
_consoleLogSource = consoleLogSource;
3730
_workerProcessFactory = defaultWorkerProcessFactory;
3831
_processRegistry = processRegistry;
3932
}
4033

41-
public IWorkerProcess Create(string workerId, string runtime, string scriptRootPath)
34+
public IWorkerProcess Create(string workerId, string runtime, string scriptRootPath, RpcWorkerConfig workerConfig)
4235
{
43-
RpcWorkerConfig workerConfig = _workerConfigs.Where(c => c.Description.Language.Equals(runtime, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
4436
ILogger workerProcessLogger = _loggerFactory.CreateLogger($"Worker.rpcWorkerProcess.{runtime}.{workerId}");
4537
return new RpcWorkerProcess(runtime, workerId, scriptRootPath, _rpcServer.Uri, workerConfig.Arguments, _eventManager, _workerProcessFactory, _processRegistry, workerProcessLogger, _consoleLogSource);
4638
}

test/WebJobs.Script.Tests/Workers/Rpc/WebHostRpcWorkerChannelManagerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public WebHostRpcWorkerChannelManagerTests()
6464
_workerOptionsMonitor = TestHelpers.CreateOptionsMonitor(_languageWorkerOptions);
6565

6666
_rpcWorkerProcessFactory = new Mock<IRpcWorkerProcessFactory>();
67-
_rpcWorkerProcessFactory.Setup(m => m.Create(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Returns(_rpcWorkerProcess.Object);
67+
_rpcWorkerProcessFactory.Setup(m => m.Create(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<RpcWorkerConfig>())).Returns(_rpcWorkerProcess.Object);
6868

6969
_testLogger = new TestLogger("WebHostLanguageWorkerChannelManagerTests");
7070
_rpcWorkerChannelFactory = new TestRpcWorkerChannelFactory(_eventManager, _testLogger, _scriptRootPath);

0 commit comments

Comments
 (0)