JS Executor: Protobuf
This commit is contained in:
parent
0271e2b8e9
commit
4a4e5ebecf
1
msa/js-executor/.gitignore
vendored
1
msa/js-executor/.gitignore
vendored
@ -29,3 +29,4 @@ pom.xml.versionsBackup
|
|||||||
**/.env
|
**/.env
|
||||||
node_modules
|
node_modules
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
api/jsinvoke.js
|
||||||
|
|||||||
@ -18,8 +18,37 @@
|
|||||||
|
|
||||||
var logger = require('../config/logger')('JsMessageConsumer');
|
var logger = require('../config/logger')('JsMessageConsumer');
|
||||||
|
|
||||||
|
var js = require('./jsinvoke').js;
|
||||||
|
|
||||||
|
|
||||||
exports.onJsInvokeMessage = function(message, producer) {
|
exports.onJsInvokeMessage = function(message, producer) {
|
||||||
|
|
||||||
logger.info('Received message: %s', message);
|
logger.info('Received message: %s', JSON.stringify(message));
|
||||||
|
|
||||||
|
var request = js.RemoteJsRequest.decode(message.value);
|
||||||
|
|
||||||
|
logger.info('Received request: %s', JSON.stringify(request));
|
||||||
|
|
||||||
|
if (request.compileRequest) {
|
||||||
|
var compileResponse = js.JsCompileResponse.create(
|
||||||
|
{
|
||||||
|
errorCode: js.JsInvokeErrorCode.COMPILATION_ERROR,
|
||||||
|
success: false,
|
||||||
|
errorDetails: 'Not Implemented!',
|
||||||
|
scriptIdLSB: request.compileRequest.scriptIdLSB,
|
||||||
|
scriptIdMSB: request.compileRequest.scriptIdMSB
|
||||||
|
}
|
||||||
|
);
|
||||||
|
var response = js.RemoteJsResponse.create(
|
||||||
|
{
|
||||||
|
compileResponse: compileResponse
|
||||||
|
}
|
||||||
|
);
|
||||||
|
var rawResponse = js.RemoteJsResponse.encode(response).finish();
|
||||||
|
sendMessage(producer, rawResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendMessage(producer, rawMessage) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,15 +6,17 @@
|
|||||||
"main": "server.js",
|
"main": "server.js",
|
||||||
"bin": "server.js",
|
"bin": "server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"install": "pkg -t node8-linux-x64,node8-win-x64 --out-path ./target . && node install.js",
|
"build-proto": "pbjs -t static-module -w commonjs -o ./api/jsinvoke.js ../../application/src/main/proto/jsinvoke.proto",
|
||||||
|
"install": "npm run build-proto && pkg -t node8-linux-x64,node8-win-x64 --out-path ./target . && node install.js",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"start": "nodemon server.js",
|
"start": "npm run build-proto && nodemon server.js",
|
||||||
"start-prod": "NODE_ENV=production nodemon server.js"
|
"start-prod": "npm run build-proto && NODE_ENV=production nodemon server.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"config": "^1.30.0",
|
"config": "^1.30.0",
|
||||||
"js-yaml": "^3.12.0",
|
"js-yaml": "^3.12.0",
|
||||||
"kafka-node": "^3.0.1",
|
"kafka-node": "^3.0.1",
|
||||||
|
"protobufjs": "^6.8.8",
|
||||||
"winston": "^3.0.0",
|
"winston": "^3.0.0",
|
||||||
"winston-daily-rotate-file": "^3.2.1"
|
"winston-daily-rotate-file": "^3.2.1"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -41,7 +41,8 @@ var kafkaClient;
|
|||||||
{ topic: kafkaRequestTopic, partition: 0 }
|
{ topic: kafkaRequestTopic, partition: 0 }
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
autoCommit: true
|
autoCommit: true,
|
||||||
|
encoding: 'buffer'
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user