Showing
4 changed files
with
38 additions
and
5 deletions
... | ... | @@ -18,8 +18,37 @@ |
18 | 18 | |
19 | 19 | var logger = require('../config/logger')('JsMessageConsumer'); |
20 | 20 | |
21 | +var js = require('./jsinvoke').js; | |
22 | + | |
23 | + | |
21 | 24 | exports.onJsInvokeMessage = function(message, producer) { |
22 | 25 | |
23 | - logger.info('Received message: %s', message); | |
26 | + logger.info('Received message: %s', JSON.stringify(message)); | |
27 | + | |
28 | + var request = js.RemoteJsRequest.decode(message.value); | |
29 | + | |
30 | + logger.info('Received request: %s', JSON.stringify(request)); | |
31 | + | |
32 | + if (request.compileRequest) { | |
33 | + var compileResponse = js.JsCompileResponse.create( | |
34 | + { | |
35 | + errorCode: js.JsInvokeErrorCode.COMPILATION_ERROR, | |
36 | + success: false, | |
37 | + errorDetails: 'Not Implemented!', | |
38 | + scriptIdLSB: request.compileRequest.scriptIdLSB, | |
39 | + scriptIdMSB: request.compileRequest.scriptIdMSB | |
40 | + } | |
41 | + ); | |
42 | + var response = js.RemoteJsResponse.create( | |
43 | + { | |
44 | + compileResponse: compileResponse | |
45 | + } | |
46 | + ); | |
47 | + var rawResponse = js.RemoteJsResponse.encode(response).finish(); | |
48 | + sendMessage(producer, rawResponse); | |
49 | + } | |
50 | +} | |
51 | + | |
52 | +function sendMessage(producer, rawMessage) { | |
24 | 53 | |
25 | 54 | } | ... | ... |
... | ... | @@ -6,15 +6,17 @@ |
6 | 6 | "main": "server.js", |
7 | 7 | "bin": "server.js", |
8 | 8 | "scripts": { |
9 | - "install": "pkg -t node8-linux-x64,node8-win-x64 --out-path ./target . && node install.js", | |
9 | + "build-proto": "pbjs -t static-module -w commonjs -o ./api/jsinvoke.js ../../application/src/main/proto/jsinvoke.proto", | |
10 | + "install": "npm run build-proto && pkg -t node8-linux-x64,node8-win-x64 --out-path ./target . && node install.js", | |
10 | 11 | "test": "echo \"Error: no test specified\" && exit 1", |
11 | - "start": "nodemon server.js", | |
12 | - "start-prod": "NODE_ENV=production nodemon server.js" | |
12 | + "start": "npm run build-proto && nodemon server.js", | |
13 | + "start-prod": "npm run build-proto && NODE_ENV=production nodemon server.js" | |
13 | 14 | }, |
14 | 15 | "dependencies": { |
15 | 16 | "config": "^1.30.0", |
16 | 17 | "js-yaml": "^3.12.0", |
17 | 18 | "kafka-node": "^3.0.1", |
19 | + "protobufjs": "^6.8.8", | |
18 | 20 | "winston": "^3.0.0", |
19 | 21 | "winston-daily-rotate-file": "^3.2.1" |
20 | 22 | }, | ... | ... |