Skip to content

Commit 928a26f

Browse files
authored
Use new worker args (#719)
1 parent 92c2e58 commit 928a26f

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

src/Worker.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,27 @@ import { startBlockedMonitor } from './utils/blockedMonitor';
1212
import { isEnvironmentVariableSet } from './utils/util';
1313

1414
export function startNodeWorker(args) {
15-
const { host, port, workerId, requestId, grpcMaxMessageLength } = parseArgs(args.slice(2));
16-
if (!host || !port || !workerId || !requestId || !grpcMaxMessageLength) {
15+
const parsedArgs = parseArgs(args.slice(2));
16+
const uri = parsedArgs['functions-uri'];
17+
const workerId = parsedArgs['functions-worker-id'];
18+
const requestId = parsedArgs['functions-request-id'];
19+
const grpcMaxMessageLength = parsedArgs['functions-grpc-max-message-length'];
20+
if (!uri || !workerId || !requestId || !grpcMaxMessageLength) {
1721
systemLog(
18-
'usage --host hostName --port portNumber --workerId workerId --requestId requestId --grpcMaxMessageLength grpcMaxMessageLength'
22+
'usage --functions-uri uri --functions-worker-id workerId --functions-request-id requestId --functions-grpc-max-message-length grpcMaxMessageLength'
1923
);
2024
// Find which arguments are in error
2125
const debugInfo: string[] = [];
22-
if (!host) debugInfo.push(`'hostName' is ${host}`);
23-
if (!port) debugInfo.push(`'port' is ${port}`);
24-
if (!workerId) debugInfo.push(`'workerId' is ${workerId}`);
25-
if (!requestId) debugInfo.push(`'requestId' is ${requestId}`);
26-
if (!grpcMaxMessageLength) debugInfo.push(`'grpcMaxMessageLength' is ${grpcMaxMessageLength}`);
26+
if (!uri) debugInfo.push(`'functions-uri' is ${uri}`);
27+
if (!workerId) debugInfo.push(`'functions-worker-id' is ${workerId}`);
28+
if (!requestId) debugInfo.push(`'functions-request-id' is ${requestId}`);
29+
if (!grpcMaxMessageLength) debugInfo.push(`'functions-grpc-max-message-length' is ${grpcMaxMessageLength}`);
2730

2831
throw new AzFuncSystemError(`gRPC client connection info is missing or incorrect (${debugInfo.join(', ')}).`);
2932
}
3033
worker.id = workerId;
3134

32-
const connection = `${host}:${port}`;
35+
const connection = new URL(uri).host;
3336
systemLog(`Worker ${workerId} connecting on ${connection}`);
3437

3538
try {

test/Worker.test.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,35 @@ describe('Worker', () => {
1010
const args = [
1111
'/node',
1212
'nodejsWorker.js',
13-
'--host',
14-
'120.0.0.0',
15-
'--port',
16-
'8000',
17-
'--workerId',
13+
'--functions-uri',
14+
'http://127.0.0.1:58870/',
15+
'--functions-worker-id',
1816
'bd2e3e80-46ba',
19-
'--requestId',
17+
'--functions-request-id',
2018
'bd2e3e80-46ba',
21-
'--grpcMaxMessageLength',
19+
'--functions-grpc-max-message-length',
2220
'0',
2321
];
2422
expect(() => {
2523
startNodeWorker(args);
26-
}).to.throw("gRPC client connection info is missing or incorrect ('grpcMaxMessageLength' is 0).");
24+
}).to.throw("gRPC client connection info is missing or incorrect ('functions-grpc-max-message-length' is 0).");
2725
});
2826

2927
it('throws error on incorrect args: grpcMaxMessageLength 0 and null requestId', () => {
3028
const args = [
3129
'/node',
3230
'nodejsWorker.js',
33-
'--host',
34-
'120.0.0.0',
35-
'--port',
36-
'8000',
37-
'--workerId',
31+
'--functions-uri',
32+
'http://127.0.0.1:58870/',
33+
'--functions-worker-id',
3834
'bd2e3e80-46ba',
39-
'--grpcMaxMessageLength',
35+
'--functions-grpc-max-message-length',
4036
'0',
4137
];
4238
expect(() => {
4339
startNodeWorker(args);
4440
}).to.throw(
45-
"gRPC client connection info is missing or incorrect ('requestId' is undefined, 'grpcMaxMessageLength' is 0)."
41+
"gRPC client connection info is missing or incorrect ('functions-request-id' is undefined, 'functions-grpc-max-message-length' is 0)."
4642
);
4743
});
4844
});

0 commit comments

Comments
 (0)