Skip to content

Commit da6e114

Browse files
authored
[V2]Add worker_directory to WorkerInitRequest (#6441) (#6467)
1 parent 53c72f9 commit da6e114

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-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: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,23 @@ internal void SendWorkerInitRequest(RpcEvent startEvent)
138138
.Take(1)
139139
.Subscribe(WorkerInitResponse, HandleWorkerInitError);
140140

141+
WorkerInitRequest initRequest = GetWorkerInitRequest();
142+
141143
SendStreamingMessage(new StreamingMessage
142144
{
143-
WorkerInitRequest = new WorkerInitRequest()
144-
{
145-
HostVersion = ScriptHost.Version
146-
}
145+
WorkerInitRequest = initRequest
147146
});
148147
}
149148

149+
internal WorkerInitRequest GetWorkerInitRequest()
150+
{
151+
return new WorkerInitRequest()
152+
{
153+
HostVersion = ScriptHost.Version,
154+
WorkerDirectory = _workerConfig.Description.WorkerDirectory
155+
};
156+
}
157+
150158
internal void FunctionEnvironmentReloadResponse(FunctionEnvironmentReloadResponse res, IDisposable latencyEvent)
151159
{
152160
_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
@@ -163,6 +163,16 @@ public void SendWorkerInitRequest_PublishesOutboundEvent()
163163
Assert.True(traces.Any(m => string.Equals(m.FormattedMessage, _expectedLogMsg)));
164164
}
165165

166+
[Fact]
167+
public void WorkerInitRequest_Expected()
168+
{
169+
WorkerInitRequest initRequest = _workerChannel.GetWorkerInitRequest();
170+
Assert.NotNull(initRequest.WorkerDirectory);
171+
Assert.NotNull(initRequest.HostVersion);
172+
Assert.Equal("testDir", initRequest.WorkerDirectory);
173+
Assert.Equal(ScriptHost.Version, initRequest.HostVersion);
174+
}
175+
166176
[Theory]
167177
[InlineData(RpcLog.Types.Level.Information, RpcLog.Types.Level.Information)]
168178
[InlineData(RpcLog.Types.Level.Error, RpcLog.Types.Level.Error)]

0 commit comments

Comments
 (0)