Skip to content

Commit d244f5c

Browse files
authored
Add worker_directory to WorkerInitRequest (#6441)
1 parent c7aa3fb commit d244f5c

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

src/WebJobs.Script.Grpc/azure-functions-language-worker-protobuf/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Azure Functions Languge Worker Protobuf
1+
# Azure Functions Language Worker Protobuf
22

33
This repository contains the protobuf definition file which defines the gRPC service which is used between the [Azure Functions Host](https://github.com/Azure/azure-functions-host) and the Azure Functions language workers. This repo is shared across many repos in many languages (for each worker) by using git commands.
44

@@ -39,7 +39,7 @@ From within the Azure Functions language worker repo:
3939
## Releasing a Language Worker Protobuf version
4040

4141
1. Draft a release in the GitHub UI
42-
- Be sure to inculde details of the release
42+
- Be sure to include details of the release
4343
2. Create a release version, following semantic versioning guidelines ([semver.org](https://semver.org/))
4444
3. Tag the version with the pattern: `v<M>.<m>.<p>-protofile` (example: `v1.1.0-protofile`)
4545
3. Merge `dev` to `master`

src/WebJobs.Script.Grpc/azure-functions-language-worker-protobuf/src/proto/FunctionRpc.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ message WorkerInitRequest {
9696
// inform worker of supported categories and their levels
9797
// i.e. Worker = Verbose, Function.MyFunc = None
9898
map<string, RpcLog.Level> log_categories = 3;
99+
100+
// Full path of worker.config.json location
101+
string worker_directory = 4;
99102
}
100103

101104
// Worker responds with the result of initializing itself

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,7 @@ internal void SendWorkerInitRequest(RpcEvent startEvent)
187187
.Take(1)
188188
.Subscribe(WorkerInitResponse, HandleWorkerInitError);
189189

190-
var initRequest = new WorkerInitRequest()
191-
{
192-
HostVersion = ScriptHost.Version,
193-
};
190+
WorkerInitRequest initRequest = GetWorkerInitRequest();
194191

195192
// Run as Functions Host V2 compatible
196193
if (_environment.IsV2CompatibilityMode())
@@ -205,6 +202,15 @@ internal void SendWorkerInitRequest(RpcEvent startEvent)
205202
});
206203
}
207204

205+
internal WorkerInitRequest GetWorkerInitRequest()
206+
{
207+
return new WorkerInitRequest()
208+
{
209+
HostVersion = ScriptHost.Version,
210+
WorkerDirectory = _workerConfig.Description.WorkerDirectory
211+
};
212+
}
213+
208214
internal void FunctionEnvironmentReloadResponse(FunctionEnvironmentReloadResponse res, IDisposable latencyEvent)
209215
{
210216
_workerChannelLogger.LogDebug("Received FunctionEnvironmentReloadResponse");

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,16 @@ public void SendWorkerInitRequest_PublishesOutboundEvent()
167167
Assert.True(traces.Any(m => string.Equals(m.FormattedMessage, _expectedLogMsg)));
168168
}
169169

170+
[Fact]
171+
public void WorkerInitRequest_Expected()
172+
{
173+
WorkerInitRequest initRequest = _workerChannel.GetWorkerInitRequest();
174+
Assert.NotNull(initRequest.WorkerDirectory);
175+
Assert.NotNull(initRequest.HostVersion);
176+
Assert.Equal("testDir", initRequest.WorkerDirectory);
177+
Assert.Equal(ScriptHost.Version, initRequest.HostVersion);
178+
}
179+
170180
[Fact]
171181
public void SendWorkerInitRequest_PublishesOutboundEvent_V2Compatable()
172182
{

0 commit comments

Comments
 (0)