Skip to content

Commit 0c0ec1c

Browse files
committed
Handle FunctionEnvironmentReloadRequest (#441)
1 parent b7e946c commit 0c0ec1c

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/RequestProcessor.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,19 @@ internal StreamingMessage ProcessInvocationCancelRequest(StreamingMessage reques
334334

335335
internal StreamingMessage ProcessFunctionEnvironmentReloadRequest(StreamingMessage request)
336336
{
337+
var stopwatch = new Stopwatch();
338+
stopwatch.Start();
339+
340+
var environmentReloadRequest = request.FunctionEnvironmentReloadRequest;
341+
foreach (var (name, value) in environmentReloadRequest.EnvironmentVariables)
342+
{
343+
Environment.SetEnvironmentVariable(name, value);
344+
}
345+
346+
var rpcLogger = new RpcLogger(_msgStream);
347+
rpcLogger.SetContext(request.RequestId, null);
348+
rpcLogger.Log(isUserOnlyLog: false, LogLevel.Trace, string.Format(PowerShellWorkerStrings.EnvironmentReloadCompleted, stopwatch.ElapsedMilliseconds));
349+
337350
StreamingMessage response = NewStreamingMessageTemplate(
338351
request.RequestId,
339352
StreamingMessage.ContentOneofCase.FunctionEnvironmentReloadResponse,

src/resources/PowerShellWorkerStrings.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,4 +313,7 @@
313313
<data name="PowerShellVersion" xml:space="preserve">
314314
<value>PowerShell version: '{0}'.</value>
315315
</data>
316+
<data name="EnvironmentReloadCompleted" xml:space="preserve">
317+
<value>Environment reload completed in {0} ms.</value>
318+
</data>
316319
</root>

0 commit comments

Comments
 (0)