Clear JS executor dependencies and code
This commit is contained in:
parent
0a1f377347
commit
d35bdcc981
@ -18,7 +18,7 @@ import config from 'config';
|
||||
import { _logger } from '../config/logger';
|
||||
import { JsExecutor, TbScript } from './jsExecutor';
|
||||
import { performance } from 'perf_hooks';
|
||||
import { isString, parseJsErrorDetails, toUUIDString, UUIDFromBuffer, UUIDToBits, isNotUUID } from './utils';
|
||||
import { isString, parseJsErrorDetails, toUUIDString, UUIDFromBuffer, UUIDToBits } from './utils';
|
||||
import { IQueue } from '../queue/queue.models';
|
||||
import {
|
||||
JsCompileRequest,
|
||||
@ -306,26 +306,14 @@ export class JsInvokeMessageProcessor {
|
||||
}
|
||||
|
||||
private static createCompileResponse(scriptId: string, success: boolean, errorCode?: number, err?: any): JsCompileResponse {
|
||||
if (isNotUUID(scriptId)) {
|
||||
return {
|
||||
errorCode: errorCode,
|
||||
success: success,
|
||||
errorDetails: parseJsErrorDetails(err),
|
||||
scriptIdMSB: "0",
|
||||
scriptIdLSB: "0",
|
||||
scriptHash: scriptId
|
||||
};
|
||||
} else { // this is for backward compatibility (to be able to work with tb-node of previous version) - todo: remove in the next release
|
||||
let scriptIdBits = UUIDToBits(scriptId);
|
||||
return {
|
||||
errorCode: errorCode,
|
||||
success: success,
|
||||
errorDetails: parseJsErrorDetails(err),
|
||||
scriptIdMSB: scriptIdBits[0],
|
||||
scriptIdLSB: scriptIdBits[1],
|
||||
scriptHash: ""
|
||||
};
|
||||
}
|
||||
return {
|
||||
errorCode: errorCode,
|
||||
success: success,
|
||||
errorDetails: parseJsErrorDetails(err),
|
||||
scriptIdMSB: "0",
|
||||
scriptIdLSB: "0",
|
||||
scriptHash: scriptId
|
||||
};
|
||||
}
|
||||
|
||||
private static createInvokeResponse(result: string | undefined, success: boolean, errorCode?: number, err?: any): JsInvokeResponse {
|
||||
@ -338,22 +326,12 @@ export class JsInvokeMessageProcessor {
|
||||
}
|
||||
|
||||
private static createReleaseResponse(scriptId: string, success: boolean): JsReleaseResponse {
|
||||
if (isNotUUID(scriptId)) {
|
||||
return {
|
||||
success: success,
|
||||
scriptIdMSB: "0",
|
||||
scriptIdLSB: "0",
|
||||
scriptHash: scriptId,
|
||||
};
|
||||
} else { // todo: remove in the next release
|
||||
let scriptIdBits = UUIDToBits(scriptId);
|
||||
return {
|
||||
success: success,
|
||||
scriptIdMSB: scriptIdBits[0],
|
||||
scriptIdLSB: scriptIdBits[1],
|
||||
scriptHash: ""
|
||||
}
|
||||
}
|
||||
return {
|
||||
success: success,
|
||||
scriptIdMSB: "0",
|
||||
scriptIdLSB: "0",
|
||||
scriptHash: scriptId,
|
||||
};
|
||||
}
|
||||
|
||||
private static getScriptId(request: TbMessage): string {
|
||||
|
||||
@ -59,10 +59,6 @@ export function parseJsErrorDetails(err: any): string | undefined {
|
||||
return details;
|
||||
}
|
||||
|
||||
export function isNotUUID(candidate: string) {
|
||||
return candidate.length != 36 || !candidate.includes('-');
|
||||
}
|
||||
|
||||
export function isNotEmptyStr(value: any): boolean {
|
||||
return typeof value === 'string' && value.trim().length > 0;
|
||||
}
|
||||
|
||||
@ -13,17 +13,12 @@
|
||||
"build": "tsc"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-sqs": "^3.682.0",
|
||||
"@azure/service-bus": "^7.9.5",
|
||||
"@google-cloud/pubsub": "^4.8.0",
|
||||
"amqplib": "^0.10.4",
|
||||
"config": "^3.3.12",
|
||||
"express": "^4.21.1",
|
||||
"js-yaml": "^4.1.0",
|
||||
"kafkajs": "^2.2.4",
|
||||
"long": "^5.2.3",
|
||||
"uuid-parse": "^1.1.0",
|
||||
"uuid-random": "^1.3.2",
|
||||
"winston": "^3.16.0",
|
||||
"winston-daily-rotate-file": "^5.0.0"
|
||||
},
|
||||
@ -36,7 +31,6 @@
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/amqplib": "^0.10.5",
|
||||
"@types/config": "^3.3.5",
|
||||
"@types/express": "~4.17.21",
|
||||
"@types/node": "~20.17.6",
|
||||
|
||||
@ -35,7 +35,6 @@ import { KeyObject } from 'tls';
|
||||
|
||||
import process, { exit, kill } from 'process';
|
||||
|
||||
// TODO: remove dependencies for other queue types
|
||||
export class KafkaTemplate implements IQueue {
|
||||
|
||||
private logger = _logger(`kafkaTemplate`);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user