@tdengine/websocket 3.1.4 → 3.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/example/basicSchemaless.js +1 -2
- package/lib/example/basicSql.js +1 -1
- package/lib/src/client/wsClient.d.ts +2 -0
- package/lib/src/client/wsClient.d.ts.map +1 -1
- package/lib/src/client/wsClient.js +20 -8
- package/lib/src/client/wsConnector.d.ts +0 -1
- package/lib/src/client/wsConnector.d.ts.map +1 -1
- package/lib/src/client/wsConnector.js +0 -3
- package/lib/src/client/wsConnectorPool.d.ts +2 -1
- package/lib/src/client/wsConnectorPool.d.ts.map +1 -1
- package/lib/src/client/wsConnectorPool.js +16 -10
- package/lib/src/client/wsEventCallback.d.ts.map +1 -1
- package/lib/src/client/wsEventCallback.js +1 -2
- package/lib/src/common/utils.d.ts +11 -0
- package/lib/src/common/utils.d.ts.map +1 -1
- package/lib/src/common/utils.js +76 -0
- package/lib/src/common/wsError.d.ts +2 -1
- package/lib/src/common/wsError.d.ts.map +1 -1
- package/lib/src/common/wsError.js +1 -0
- package/lib/src/sql/wsRows.js +2 -2
- package/lib/src/sql/wsSql.d.ts +0 -1
- package/lib/src/sql/wsSql.d.ts.map +1 -1
- package/lib/src/sql/wsSql.js +6 -14
- package/lib/src/stmt/wsStmt.d.ts +0 -4
- package/lib/src/stmt/wsStmt.d.ts.map +1 -1
- package/lib/src/stmt/wsStmt.js +3 -8
- package/lib/src/tmq/config.d.ts +8 -6
- package/lib/src/tmq/config.d.ts.map +1 -1
- package/lib/src/tmq/config.js +46 -17
- package/lib/src/tmq/wsTmq.d.ts.map +1 -1
- package/lib/src/tmq/wsTmq.js +26 -2
- package/lib/test/bulkPulling/sql.test.js +32 -0
- package/lib/test/bulkPulling/stmt.type.test.js +1 -1
- package/lib/test/bulkPulling/tmq.test.js +9 -3
- package/lib/test/bulkPulling/utils.test.d.ts +2 -0
- package/lib/test/bulkPulling/utils.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/utils.test.js +13 -0
- package/lib/test/bulkPulling/wsConnectPool.test.js +6 -5
- package/package.json +5 -9
- package/lib/example/logs/.007e668bb78549e9a304b8466671945ab2a1553e-audit.json +0 -15
- package/lib/example/logs/app-2025-01-24.log +0 -5580
|
@@ -17,7 +17,7 @@ async function Prepare() {
|
|
|
17
17
|
await wsSql.exec(dropDB);
|
|
18
18
|
await wsSql.exec('create database if not exists power KEEP 3650 DURATION 10 BUFFER 16 WAL_LEVEL 1;');
|
|
19
19
|
await wsSql.exec('CREATE STABLE if not exists power.meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int);');
|
|
20
|
-
wsSql.close();
|
|
20
|
+
await wsSql.close();
|
|
21
21
|
}
|
|
22
22
|
(async () => {
|
|
23
23
|
let wsSchemaless = null;
|
|
@@ -31,7 +31,6 @@ async function Prepare() {
|
|
|
31
31
|
await wsSchemaless.schemalessInsert([influxdbData], wsProto_1.SchemalessProto.InfluxDBLineProtocol, wsProto_1.Precision.NANO_SECONDS, 0);
|
|
32
32
|
await wsSchemaless.schemalessInsert([telnetData], wsProto_1.SchemalessProto.OpenTSDBTelnetLineProtocol, wsProto_1.Precision.SECONDS, 0);
|
|
33
33
|
await wsSchemaless.schemalessInsert([jsonData], wsProto_1.SchemalessProto.OpenTSDBJsonFormatProtocol, wsProto_1.Precision.SECONDS, 0);
|
|
34
|
-
wsSchemaless.close();
|
|
35
34
|
}
|
|
36
35
|
catch (e) {
|
|
37
36
|
console.error(e);
|
package/lib/example/basicSql.js
CHANGED
|
@@ -3,6 +3,7 @@ export declare class WsClient {
|
|
|
3
3
|
private _wsConnector?;
|
|
4
4
|
private _timeout?;
|
|
5
5
|
private readonly _url;
|
|
6
|
+
private static readonly _minVersion;
|
|
6
7
|
constructor(url: URL, timeout?: number | undefined | null);
|
|
7
8
|
connect(database?: string | undefined | null): Promise<void>;
|
|
8
9
|
execNoResp(queryMsg: string): Promise<void>;
|
|
@@ -15,5 +16,6 @@ export declare class WsClient {
|
|
|
15
16
|
version(): Promise<string>;
|
|
16
17
|
close(): Promise<void>;
|
|
17
18
|
checkURL(url: URL): void;
|
|
19
|
+
checkVersion(): Promise<void>;
|
|
18
20
|
}
|
|
19
21
|
//# sourceMappingURL=wsClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsClient.d.ts","sourceRoot":"","sources":["../../../src/client/wsClient.ts"],"names":[],"mappings":"AAIA,OAAO,EAEH,eAAe,EAClB,MAAM,cAAc,CAAC;AAKtB,qBAAa,QAAQ;IACjB,OAAO,CAAC,YAAY,CAAC,CAAqB;IAC1C,OAAO,CAAC,QAAQ,CAAC,CAA2B;IAC5C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAK;
|
|
1
|
+
{"version":3,"file":"wsClient.d.ts","sourceRoot":"","sources":["../../../src/client/wsClient.ts"],"names":[],"mappings":"AAIA,OAAO,EAEH,eAAe,EAClB,MAAM,cAAc,CAAC;AAKtB,qBAAa,QAAQ;IACjB,OAAO,CAAC,YAAY,CAAC,CAAqB;IAC1C,OAAO,CAAC,QAAQ,CAAC,CAA2B;IAC5C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAK;IAC1B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAa;gBAEpC,GAAG,EAAE,GAAG,EAAE,OAAQ,CAAC,EAAC,MAAM,GAAG,SAAS,GAAG,IAAI;IAOnD,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAsC5D,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3C,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,GAAC,OAAc,GAAG,OAAO,CAAC,GAAG,CAAC;IAuB9D,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,GAAC,OAAc,EAAE,aAAa,GAAE,OAAe,GAAG,OAAO,CAAC,GAAG,CAAC;IA0B/I,QAAQ;IAQF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAetB,OAAO,CAAC,GAAG,EAAC,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAajC,UAAU,CAAC,GAAG,EAAE,eAAe;IAqB/B,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IA4B1B,KAAK,IAAG,OAAO,CAAC,IAAI,CAAC;IAS3B,QAAQ,CAAC,GAAG,EAAE,GAAG;IASX,YAAY;CAQrB"}
|
|
@@ -10,6 +10,7 @@ const wsError_1 = require("../common/wsError");
|
|
|
10
10
|
const wsResponse_1 = require("./wsResponse");
|
|
11
11
|
const reqid_1 = require("../common/reqid");
|
|
12
12
|
const log_1 = __importDefault(require("../common/log"));
|
|
13
|
+
const utils_1 = require("../common/utils");
|
|
13
14
|
class WsClient {
|
|
14
15
|
constructor(url, timeout) {
|
|
15
16
|
this.checkURL(url);
|
|
@@ -25,8 +26,8 @@ class WsClient {
|
|
|
25
26
|
action: 'conn',
|
|
26
27
|
args: {
|
|
27
28
|
req_id: reqid_1.ReqId.getReqID(),
|
|
28
|
-
user: this._url.username,
|
|
29
|
-
password: this._url.password,
|
|
29
|
+
user: (0, utils_1.safeDecodeURIComponent)(this._url.username),
|
|
30
|
+
password: (0, utils_1.safeDecodeURIComponent)(this._url.password),
|
|
30
31
|
db: _db,
|
|
31
32
|
},
|
|
32
33
|
};
|
|
@@ -40,11 +41,13 @@ class WsClient {
|
|
|
40
41
|
if (result.msg.code == 0) {
|
|
41
42
|
return;
|
|
42
43
|
}
|
|
44
|
+
await this.close();
|
|
43
45
|
throw (new wsError_1.WebSocketQueryError(result.msg.code, result.msg.message));
|
|
44
46
|
}
|
|
45
47
|
catch (e) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
await this.close();
|
|
49
|
+
log_1.default.error(`connection creation failed, url: ${this._url}, code:${e.code}, msg:${e.message}`);
|
|
50
|
+
throw (new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `connection creation failed, url: ${this._url}, code:${e.code}, msg:${e.message}`));
|
|
48
51
|
}
|
|
49
52
|
}
|
|
50
53
|
async execNoResp(queryMsg) {
|
|
@@ -121,8 +124,8 @@ class WsClient {
|
|
|
121
124
|
return;
|
|
122
125
|
}
|
|
123
126
|
catch (e) {
|
|
124
|
-
log_1.default.error(e.code, e.message);
|
|
125
|
-
throw (new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `connection creation failed, url: ${this._url}`));
|
|
127
|
+
log_1.default.error(`connection creation failed, url: ${this._url}, code: ${e.code}, message: ${e.message}`);
|
|
128
|
+
throw (new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `connection creation failed, url: ${this._url}, code: ${e.code}, message: ${e.message}`));
|
|
126
129
|
}
|
|
127
130
|
}
|
|
128
131
|
async sendMsg(msg) {
|
|
@@ -178,8 +181,8 @@ class WsClient {
|
|
|
178
181
|
throw (new wsError_1.WebSocketInterfaceError(result.msg.code, result.msg.message));
|
|
179
182
|
}
|
|
180
183
|
catch (e) {
|
|
181
|
-
log_1.default.error(e.code, e.message);
|
|
182
|
-
throw (new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `connection creation failed, url: ${this._url}`));
|
|
184
|
+
log_1.default.error(`connection creation failed, url: ${this._url}, code: ${e.code}, message: ${e.message}`);
|
|
185
|
+
throw (new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `connection creation failed, url: ${this._url}, code: ${e.code}, message: ${e.message}`));
|
|
183
186
|
}
|
|
184
187
|
}
|
|
185
188
|
throw (wsError_1.ErrorCode.ERR_CONNECTION_CLOSED, "invalid websocket connect");
|
|
@@ -199,5 +202,14 @@ class WsClient {
|
|
|
199
202
|
}
|
|
200
203
|
}
|
|
201
204
|
}
|
|
205
|
+
async checkVersion() {
|
|
206
|
+
let version = await this.version();
|
|
207
|
+
let result = (0, utils_1.compareVersions)(version, WsClient._minVersion);
|
|
208
|
+
if (result < 0) {
|
|
209
|
+
log_1.default.error(`TDengine version is too low, current version: ${version}, minimum required version: ${WsClient._minVersion}`);
|
|
210
|
+
throw (new wsError_1.WebSocketQueryError(wsError_1.ErrorCode.ERR_TDENIGNE_VERSION_IS_TOO_LOW, `Version mismatch. The minimum required TDengine version is ${WsClient._minVersion}`));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
202
213
|
}
|
|
203
214
|
exports.WsClient = WsClient;
|
|
215
|
+
WsClient._minVersion = "3.3.2.0";
|
|
@@ -11,7 +11,6 @@ export declare class WebSocketConnector {
|
|
|
11
11
|
sendMsgNoResp(message: string): Promise<void>;
|
|
12
12
|
sendMsg(message: string, register?: Boolean): Promise<unknown>;
|
|
13
13
|
sendBinaryMsg(reqId: bigint, action: string, message: ArrayBuffer, register?: Boolean): Promise<unknown>;
|
|
14
|
-
configTimeout(ms: number): void;
|
|
15
14
|
getWsURL(): URL;
|
|
16
15
|
}
|
|
17
16
|
//# sourceMappingURL=wsConnector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsConnector.d.ts","sourceRoot":"","sources":["../../../src/client/wsConnector.ts"],"names":[],"mappings":"AAMA,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,MAAM,CAAM;IACpB,QAAQ,SAAQ;gBAGJ,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAsBlD,KAAK;
|
|
1
|
+
{"version":3,"file":"wsConnector.d.ts","sourceRoot":"","sources":["../../../src/client/wsConnector.ts"],"names":[],"mappings":"AAMA,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,MAAM,CAAM;IACpB,QAAQ,SAAQ;gBAGJ,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAsBlD,KAAK;YAcG,QAAQ;IAKtB,OAAO,CAAC,UAAU;IA0BlB,KAAK;IASL,UAAU,IAAI,MAAM;IAId,aAAa,CAAC,OAAO,EAAE,MAAM,GAAE,OAAO,CAAC,IAAI,CAAC;IAmB5C,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAE,OAAc;IAuBjD,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,GAAE,OAAc;IAgBzF,QAAQ,IAAI,GAAG;CAGzB"}
|
|
@@ -2,8 +2,9 @@ import { WebSocketConnector } from "./wsConnector";
|
|
|
2
2
|
export declare class WebSocketConnectionPool {
|
|
3
3
|
private static _instance?;
|
|
4
4
|
private pool;
|
|
5
|
-
private _connectionCount;
|
|
6
5
|
private readonly _maxConnections;
|
|
6
|
+
private static sharedBuffer;
|
|
7
|
+
private static sharedArray;
|
|
7
8
|
private constructor();
|
|
8
9
|
static instance(maxConnections?: number): WebSocketConnectionPool;
|
|
9
10
|
getConnection(url: URL, timeout: number | undefined | null): Promise<WebSocketConnector>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsConnectorPool.d.ts","sourceRoot":"","sources":["../../../src/client/wsConnectorPool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"wsConnectorPool.d.ts","sourceRoot":"","sources":["../../../src/client/wsConnectorPool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAQnD,qBAAa,uBAAuB;IAChC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAyB;IAClD,OAAO,CAAC,IAAI,CAAgD;IAC5D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAoB;IAC/C,OAAO,CAAC,MAAM,CAAC,WAAW,CAAa;IAEvC,OAAO;WAOO,QAAQ,CAAC,cAAc,GAAE,MAAW,GAAE,uBAAuB;IAOrE,aAAa,CAAC,GAAG,EAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA8BvF,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,GAAE,OAAO,CAAC,IAAI,CAAC;IA4BpE,SAAS;CAcZ"}
|
|
@@ -13,7 +13,9 @@ class WebSocketConnectionPool {
|
|
|
13
13
|
constructor(maxConnections = -1) {
|
|
14
14
|
this.pool = new Map();
|
|
15
15
|
this._maxConnections = maxConnections;
|
|
16
|
-
|
|
16
|
+
WebSocketConnectionPool.sharedBuffer = new SharedArrayBuffer(4);
|
|
17
|
+
WebSocketConnectionPool.sharedArray = new Int32Array(WebSocketConnectionPool.sharedBuffer);
|
|
18
|
+
Atomics.store(WebSocketConnectionPool.sharedArray, 0, 0);
|
|
17
19
|
}
|
|
18
20
|
static instance(maxConnections = -1) {
|
|
19
21
|
if (!WebSocketConnectionPool._instance) {
|
|
@@ -23,7 +25,6 @@ class WebSocketConnectionPool {
|
|
|
23
25
|
}
|
|
24
26
|
async getConnection(url, timeout) {
|
|
25
27
|
let connectAddr = url.origin.concat(url.pathname).concat(url.search);
|
|
26
|
-
log_1.default.info("url:" + url);
|
|
27
28
|
let connector;
|
|
28
29
|
const unlock = await mutex.acquire();
|
|
29
30
|
try {
|
|
@@ -36,13 +37,14 @@ class WebSocketConnectionPool {
|
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
if (connector) {
|
|
39
|
-
log_1.default.debug("get connection success:" +
|
|
40
|
+
log_1.default.debug("get connection success:" + Atomics.load(WebSocketConnectionPool.sharedArray, 0));
|
|
40
41
|
return connector;
|
|
41
42
|
}
|
|
42
|
-
if (this._maxConnections != -1 &&
|
|
43
|
-
throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_ARRIVED_LIMIT, "websocket connect arrived limited:" +
|
|
43
|
+
if (this._maxConnections != -1 && Atomics.load(WebSocketConnectionPool.sharedArray, 0) > this._maxConnections) {
|
|
44
|
+
throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_ARRIVED_LIMIT, "websocket connect arrived limited:" + Atomics.load(WebSocketConnectionPool.sharedArray, 0));
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
+
Atomics.add(WebSocketConnectionPool.sharedArray, 0, 1);
|
|
47
|
+
log_1.default.info("getConnection, new connection count:" + Atomics.load(WebSocketConnectionPool.sharedArray, 0) + ", connectAddr:" + connectAddr);
|
|
46
48
|
return new wsConnector_1.WebSocketConnector(url, timeout);
|
|
47
49
|
}
|
|
48
50
|
finally {
|
|
@@ -65,10 +67,12 @@ class WebSocketConnectionPool {
|
|
|
65
67
|
else {
|
|
66
68
|
connectors.push(connector);
|
|
67
69
|
}
|
|
70
|
+
log_1.default.info("releaseConnection, current connection count:" + connectors.length);
|
|
68
71
|
}
|
|
69
72
|
else {
|
|
70
|
-
|
|
73
|
+
Atomics.add(WebSocketConnectionPool.sharedArray, 0, -1);
|
|
71
74
|
connector.close();
|
|
75
|
+
log_1.default.info("releaseConnection, current connection status fail:" + Atomics.load(WebSocketConnectionPool.sharedArray, 0));
|
|
72
76
|
}
|
|
73
77
|
}
|
|
74
78
|
finally {
|
|
@@ -77,15 +81,17 @@ class WebSocketConnectionPool {
|
|
|
77
81
|
}
|
|
78
82
|
}
|
|
79
83
|
destroyed() {
|
|
84
|
+
let num = 0;
|
|
80
85
|
if (this.pool) {
|
|
81
86
|
for (let values of this.pool.values()) {
|
|
82
87
|
for (let i in values) {
|
|
83
|
-
|
|
88
|
+
num++;
|
|
89
|
+
values[i].close();
|
|
84
90
|
}
|
|
85
91
|
}
|
|
86
92
|
}
|
|
87
|
-
log_1.default.info("destroyed connect:" +
|
|
88
|
-
|
|
93
|
+
log_1.default.info("destroyed connect:" + Atomics.load(WebSocketConnectionPool.sharedArray, 0) + " current count:" + num);
|
|
94
|
+
Atomics.store(WebSocketConnectionPool.sharedArray, 0, 0);
|
|
89
95
|
this.pool = new Map();
|
|
90
96
|
}
|
|
91
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsEventCallback.d.ts","sourceRoot":"","sources":["../../../src/client/wsEventCallback.ts"],"names":[],"mappings":"AAKA,UAAU,SAAS;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAC,MAAM,CAAA;CAClB;AASD,oBAAY,aAAa;IACrB,wBAAwB,IAAI;IAC5B,iBAAiB,IAAI;IACrB,mBAAmB,IAAI;IACvB,uBAAuB,IAAI;CAC9B;AAGD,qBAAa,eAAe;IACxB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAiB;IAC1C,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAA4C;IAC7E,OAAO;WAGO,QAAQ,IAAG,eAAe;IAOlC,gBAAgB,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI;IAgBxF,mBAAmB,CAAC,GAAG,EAAE,SAAS,EAAE,WAAW,EAAC,aAAa,EAAE,IAAI,EAAC,GAAG;
|
|
1
|
+
{"version":3,"file":"wsEventCallback.d.ts","sourceRoot":"","sources":["../../../src/client/wsEventCallback.ts"],"names":[],"mappings":"AAKA,UAAU,SAAS;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAC,MAAM,CAAA;CAClB;AASD,oBAAY,aAAa;IACrB,wBAAwB,IAAI;IAC5B,iBAAiB,IAAI;IACrB,mBAAmB,IAAI;IACvB,uBAAuB,IAAI;CAC9B;AAGD,qBAAa,eAAe;IACxB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAiB;IAC1C,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAA4C;IAC7E,OAAO;WAGO,QAAQ,IAAG,eAAe;IAOlC,gBAAgB,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI;IAgBxF,mBAAmB,CAAC,GAAG,EAAE,SAAS,EAAE,WAAW,EAAC,aAAa,EAAE,IAAI,EAAC,GAAG;CAmDhF"}
|
|
@@ -40,9 +40,8 @@ class WsEventCallback {
|
|
|
40
40
|
}
|
|
41
41
|
async handleEventCallback(msg, messageType, data) {
|
|
42
42
|
let action = undefined;
|
|
43
|
-
log_1.default.debug("HandleEventCallback msg=", msg, messageType);
|
|
44
43
|
let release = await eventMutex.acquire();
|
|
45
|
-
log_1.default.debug(
|
|
44
|
+
log_1.default.debug(`HandleEventCallback get lock msg=${msg}, ${messageType}`);
|
|
46
45
|
log_1.default.debug(WsEventCallback._msgActionRegister);
|
|
47
46
|
try {
|
|
48
47
|
for (let [k, v] of WsEventCallback._msgActionRegister) {
|
|
@@ -3,4 +3,15 @@ export declare function getUrl(wsConfig: WSConfig): URL;
|
|
|
3
3
|
export declare function isEmpty(value: any): boolean;
|
|
4
4
|
export declare function getBinarySql(action: bigint, reqId: bigint, resultId: bigint, sql?: string): ArrayBuffer;
|
|
5
5
|
export declare function zigzagDecode(n: number): number;
|
|
6
|
+
export declare function safeDecodeURIComponent(str: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* compare two semantic version numbers
|
|
9
|
+
* @param v1 (e.g., "3.3.6.3-alpha")
|
|
10
|
+
* @param v2 (e.g., "3.3.6.2")
|
|
11
|
+
* @returns
|
|
12
|
+
* 1 -> v1 > v2
|
|
13
|
+
* -1 -> v1 < v2
|
|
14
|
+
* 0 -> v1 === v2
|
|
15
|
+
*/
|
|
16
|
+
export declare function compareVersions(v1: string, v2: string): number;
|
|
6
17
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/common/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/common/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpC,wBAAgB,MAAM,CAAC,QAAQ,EAAC,QAAQ,GAAE,GAAG,CAe5C;AAGD,wBAAgB,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAM3C;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM,EAAE,GAAG,CAAC,EAAC,MAAM,GAAG,WAAW,CA6BnG;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,UAQjD;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAW9D"}
|
package/lib/src/common/utils.js
CHANGED
|
@@ -4,6 +4,9 @@ exports.getUrl = getUrl;
|
|
|
4
4
|
exports.isEmpty = isEmpty;
|
|
5
5
|
exports.getBinarySql = getBinarySql;
|
|
6
6
|
exports.zigzagDecode = zigzagDecode;
|
|
7
|
+
exports.safeDecodeURIComponent = safeDecodeURIComponent;
|
|
8
|
+
exports.compareVersions = compareVersions;
|
|
9
|
+
const wsError_1 = require("./wsError");
|
|
7
10
|
function getUrl(wsConfig) {
|
|
8
11
|
let url = new URL(wsConfig.getUrl());
|
|
9
12
|
if (wsConfig.getUser()) {
|
|
@@ -59,3 +62,76 @@ function getBinarySql(action, reqId, resultId, sql) {
|
|
|
59
62
|
function zigzagDecode(n) {
|
|
60
63
|
return (n >> 1) ^ (-(n & 1));
|
|
61
64
|
}
|
|
65
|
+
function safeDecodeURIComponent(str) {
|
|
66
|
+
// Replace invalid "%" not followed by two hex characters with "%25"
|
|
67
|
+
const cleaned = str.replace(/%(?![0-9A-Fa-f]{2})/g, '%25');
|
|
68
|
+
try {
|
|
69
|
+
return decodeURIComponent(cleaned);
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
throw (new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_INVALID_URL, `Decoding ${str} error: ${e}`));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* compare two semantic version numbers
|
|
77
|
+
* @param v1 (e.g., "3.3.6.3-alpha")
|
|
78
|
+
* @param v2 (e.g., "3.3.6.2")
|
|
79
|
+
* @returns
|
|
80
|
+
* 1 -> v1 > v2
|
|
81
|
+
* -1 -> v1 < v2
|
|
82
|
+
* 0 -> v1 === v2
|
|
83
|
+
*/
|
|
84
|
+
function compareVersions(v1, v2) {
|
|
85
|
+
// analyze the core part of the version number and pre release tags
|
|
86
|
+
const [main1, pre1] = splitVersion(v1);
|
|
87
|
+
const [main2, pre2] = splitVersion(v2);
|
|
88
|
+
// compare the main version number section
|
|
89
|
+
const mainComparison = compareMainVersions(main1, main2);
|
|
90
|
+
if (mainComparison !== 0)
|
|
91
|
+
return mainComparison;
|
|
92
|
+
// comparing pre release tags with the same main version
|
|
93
|
+
return comparePreReleases(pre1, pre2);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Split version number into main version and pre release tags
|
|
97
|
+
*/
|
|
98
|
+
function splitVersion(version) {
|
|
99
|
+
// split main version and pre release tags
|
|
100
|
+
const parts = version.split('-');
|
|
101
|
+
const main = parts[0];
|
|
102
|
+
const prerelease = parts.length > 1 ? parts[1] : null;
|
|
103
|
+
// split the main version into a numerical array
|
|
104
|
+
const mainParts = main.split('.').map(Number);
|
|
105
|
+
return [mainParts, prerelease];
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* compare the main version number section
|
|
109
|
+
*/
|
|
110
|
+
function compareMainVersions(v1, v2) {
|
|
111
|
+
const maxLength = Math.max(v1.length, v2.length);
|
|
112
|
+
for (let i = 0; i < maxLength; i++) {
|
|
113
|
+
// if partially missing, it is considered as 0
|
|
114
|
+
const part1 = v1[i] || 0;
|
|
115
|
+
const part2 = v2[i] || 0;
|
|
116
|
+
if (part1 > part2)
|
|
117
|
+
return 1;
|
|
118
|
+
if (part1 < part2)
|
|
119
|
+
return -1;
|
|
120
|
+
}
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* compare pre release tags
|
|
125
|
+
*/
|
|
126
|
+
function comparePreReleases(pre1, pre2) {
|
|
127
|
+
// both have no pre release tags → equal
|
|
128
|
+
if (pre1 === null && pre2 === null)
|
|
129
|
+
return 0;
|
|
130
|
+
// versions with pre release tags have lower priority
|
|
131
|
+
if (pre1 === null)
|
|
132
|
+
return 1; // v1 is stable > v2
|
|
133
|
+
if (pre2 === null)
|
|
134
|
+
return -1; // v2 is stable > v1
|
|
135
|
+
// compare pre release tag strings
|
|
136
|
+
return pre1.localeCompare(pre2);
|
|
137
|
+
}
|
|
@@ -24,6 +24,7 @@ export declare enum ErrorCode {
|
|
|
24
24
|
ERR_CONNECTION_CLOSED = 108,
|
|
25
25
|
ERR_INVALID_FETCH_MESSAGE_DATA = 109,
|
|
26
26
|
ERR_WEBSOCKET_CONNECTION_ARRIVED_LIMIT = 110,
|
|
27
|
-
ERR_PARTITIONS_TOPIC_VGROUP_LENGTH_NOT_EQUAL = 111
|
|
27
|
+
ERR_PARTITIONS_TOPIC_VGROUP_LENGTH_NOT_EQUAL = 111,
|
|
28
|
+
ERR_TDENIGNE_VERSION_IS_TOO_LOW = 112
|
|
28
29
|
}
|
|
29
30
|
//# sourceMappingURL=wsError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsError.d.ts","sourceRoot":"","sources":["../../../src/common/wsError.ts"],"names":[],"mappings":"AAAA,qBAAa,sBAAuB,SAAQ,KAAK;IAC7C,IAAI,EAAC,MAAM,CAAK;gBACJ,IAAI,EAAC,MAAM,EAAE,OAAO,GAAE,MAAW;CAahD;AACD,qBAAa,mBAAoB,SAAQ,sBAAsB;CAAI;AACnE,qBAAa,uBAAwB,SAAQ,sBAAsB;CAAG;AACtE,qBAAa,4BAA6B,SAAQ,uBAAuB;CAAE;AAC3E,qBAAa,eAAgB,SAAQ,sBAAsB;CAAE;AAC7D,qBAAa,SAAU,SAAQ,sBAAsB;CAAE;AAEvD,oBAAY,SAAS;IACjB,kBAAkB,MAAM;IACxB,eAAe,MAAM;IACrB,kBAAkB,MAAM;IACxB,wBAAwB,MAAM;IAC9B,6BAA6B,MAAM;IACnC,2BAA2B,MAAM;IACjC,0BAA0B,MAAM;IAChC,6BAA6B,MAAM;IACnC,qBAAqB,MAAM;IAC3B,8BAA8B,MAAM;IACpC,sCAAsC,MAAM;IAC5C,4CAA4C,MAAM;
|
|
1
|
+
{"version":3,"file":"wsError.d.ts","sourceRoot":"","sources":["../../../src/common/wsError.ts"],"names":[],"mappings":"AAAA,qBAAa,sBAAuB,SAAQ,KAAK;IAC7C,IAAI,EAAC,MAAM,CAAK;gBACJ,IAAI,EAAC,MAAM,EAAE,OAAO,GAAE,MAAW;CAahD;AACD,qBAAa,mBAAoB,SAAQ,sBAAsB;CAAI;AACnE,qBAAa,uBAAwB,SAAQ,sBAAsB;CAAG;AACtE,qBAAa,4BAA6B,SAAQ,uBAAuB;CAAE;AAC3E,qBAAa,eAAgB,SAAQ,sBAAsB;CAAE;AAC7D,qBAAa,SAAU,SAAQ,sBAAsB;CAAE;AAEvD,oBAAY,SAAS;IACjB,kBAAkB,MAAM;IACxB,eAAe,MAAM;IACrB,kBAAkB,MAAM;IACxB,wBAAwB,MAAM;IAC9B,6BAA6B,MAAM;IACnC,2BAA2B,MAAM;IACjC,0BAA0B,MAAM;IAChC,6BAA6B,MAAM;IACnC,qBAAqB,MAAM;IAC3B,8BAA8B,MAAM;IACpC,sCAAsC,MAAM;IAC5C,4CAA4C,MAAM;IAClD,+BAA+B,MAAM;CACxC"}
|
|
@@ -48,4 +48,5 @@ var ErrorCode;
|
|
|
48
48
|
ErrorCode[ErrorCode["ERR_INVALID_FETCH_MESSAGE_DATA"] = 109] = "ERR_INVALID_FETCH_MESSAGE_DATA";
|
|
49
49
|
ErrorCode[ErrorCode["ERR_WEBSOCKET_CONNECTION_ARRIVED_LIMIT"] = 110] = "ERR_WEBSOCKET_CONNECTION_ARRIVED_LIMIT";
|
|
50
50
|
ErrorCode[ErrorCode["ERR_PARTITIONS_TOPIC_VGROUP_LENGTH_NOT_EQUAL"] = 111] = "ERR_PARTITIONS_TOPIC_VGROUP_LENGTH_NOT_EQUAL";
|
|
51
|
+
ErrorCode[ErrorCode["ERR_TDENIGNE_VERSION_IS_TOO_LOW"] = 112] = "ERR_TDENIGNE_VERSION_IS_TOO_LOW";
|
|
51
52
|
})(ErrorCode || (exports.ErrorCode = ErrorCode = {}));
|
package/lib/src/sql/wsRows.js
CHANGED
|
@@ -47,7 +47,7 @@ class WSRows {
|
|
|
47
47
|
throw new wsError_1.TaosResultError(wsResponse.code, wsResponse.message);
|
|
48
48
|
}
|
|
49
49
|
if (wsResponse.finished == 1) {
|
|
50
|
-
this.close();
|
|
50
|
+
await this.close();
|
|
51
51
|
this._taosResult.setData(null);
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
@@ -57,7 +57,7 @@ class WSRows {
|
|
|
57
57
|
return this._taosResult;
|
|
58
58
|
}
|
|
59
59
|
catch (err) {
|
|
60
|
-
this.close();
|
|
60
|
+
await this.close();
|
|
61
61
|
throw new wsError_1.TaosResultError(err.code, err.message);
|
|
62
62
|
}
|
|
63
63
|
}
|
package/lib/src/sql/wsSql.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsSql.d.ts","sourceRoot":"","sources":["../../../src/sql/wsSql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAc,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAG7D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAG3C,OAAO,EAAE,SAAS,EAAyB,eAAe,EAAE,MAAM,WAAW,CAAA;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAKvC,qBAAa,KAAK;IACd,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,SAAS,CAAW;gBAChB,QAAQ,EAAC,QAAQ;WAMhB,IAAI,CAAC,QAAQ,EAAC,QAAQ,GAAE,OAAO,CAAC,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"wsSql.d.ts","sourceRoot":"","sources":["../../../src/sql/wsSql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAc,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAG7D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAG3C,OAAO,EAAE,SAAS,EAAyB,eAAe,EAAE,MAAM,WAAW,CAAA;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAKvC,qBAAa,KAAK;IACd,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,SAAS,CAAW;gBAChB,QAAQ,EAAC,QAAQ;WAMhB,IAAI,CAAC,QAAQ,EAAC,QAAQ,GAAE,OAAO,CAAC,KAAK,CAAC;IAuBnD,KAAK;IAIL;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAI1B,KAAK,IAAG,OAAO,CAAC,IAAI,CAAC;IAIrB,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BnI,QAAQ,CAAC,KAAK,CAAC,EAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAuBxC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,GAAC,MAAuB,GAAG,OAAO,CAAC,UAAU,CAAC;YA4C9E,uBAAuB;IAa/B,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAW3D"}
|
package/lib/src/sql/wsSql.js
CHANGED
|
@@ -28,13 +28,17 @@ class WsSql {
|
|
|
28
28
|
let database = wsConfig.getDb();
|
|
29
29
|
try {
|
|
30
30
|
await wsSql._wsClient.connect(database);
|
|
31
|
+
await wsSql._wsClient.checkVersion();
|
|
31
32
|
if (database && database.length > 0) {
|
|
32
33
|
await wsSql.exec(`use ${database}`);
|
|
33
34
|
}
|
|
34
35
|
return wsSql;
|
|
35
36
|
}
|
|
36
37
|
catch (e) {
|
|
37
|
-
log_1.default.error(e.code, e.message);
|
|
38
|
+
log_1.default.error(`WsSql open is failed, ${e.code}, ${e.message}`);
|
|
39
|
+
if (wsSql) {
|
|
40
|
+
await wsSql.close();
|
|
41
|
+
}
|
|
38
42
|
throw (e);
|
|
39
43
|
}
|
|
40
44
|
}
|
|
@@ -88,7 +92,7 @@ class WsSql {
|
|
|
88
92
|
return await wsStmt_1.WsStmt.newStmt(this._wsClient, precision, reqId);
|
|
89
93
|
}
|
|
90
94
|
catch (e) {
|
|
91
|
-
log_1.default.error(e.code, e.message);
|
|
95
|
+
log_1.default.error(`stmtInit failed, code: ${e.code}, message: ${e.message}`);
|
|
92
96
|
throw (e);
|
|
93
97
|
}
|
|
94
98
|
}
|
|
@@ -158,17 +162,5 @@ class WsSql {
|
|
|
158
162
|
throw new wsError_1.TaosResultError(err.code, err.message);
|
|
159
163
|
}
|
|
160
164
|
}
|
|
161
|
-
getSql(sql, reqId, action = 'query') {
|
|
162
|
-
// construct msg
|
|
163
|
-
let queryMsg = {
|
|
164
|
-
action: action,
|
|
165
|
-
args: {
|
|
166
|
-
req_id: reqid_1.ReqId.getReqID(reqId),
|
|
167
|
-
sql: sql,
|
|
168
|
-
id: 0
|
|
169
|
-
},
|
|
170
|
-
};
|
|
171
|
-
return JSON.stringify(queryMsg);
|
|
172
|
-
}
|
|
173
165
|
}
|
|
174
166
|
exports.WsSql = WsSql;
|
package/lib/src/stmt/wsStmt.d.ts
CHANGED
|
@@ -15,10 +15,6 @@ export declare class WsStmt {
|
|
|
15
15
|
bind(paramsArray: StmtBindParams): Promise<void>;
|
|
16
16
|
jsonBind(paramArray: Array<Array<any>>): Promise<void>;
|
|
17
17
|
batch(): Promise<void>;
|
|
18
|
-
/**
|
|
19
|
-
* return client version.
|
|
20
|
-
*/
|
|
21
|
-
version(): Promise<string>;
|
|
22
18
|
exec(): Promise<void>;
|
|
23
19
|
getLastAffected(): number | null | undefined;
|
|
24
20
|
close(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsStmt.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsStmt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAK9C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,qBAAa,MAAM;IACf,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,UAAU,CAAgC;IAElD,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO;WAOM,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAC,MAAM,EAAE,KAAK,CAAC,EAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAWrF,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYnC,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAY9C,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAYlD,YAAY,IAAG,cAAc;IAIvB,OAAO,CAAC,WAAW,EAAC,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAclD,IAAI,CAAC,WAAW,EAAC,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAc/C,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAYtD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"wsStmt.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsStmt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAK9C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,qBAAa,MAAM;IACf,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,UAAU,CAAgC;IAElD,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO;WAOM,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAC,MAAM,EAAE,KAAK,CAAC,EAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAWrF,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYnC,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAY9C,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAYlD,YAAY,IAAG,cAAc;IAIvB,OAAO,CAAC,WAAW,EAAC,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAclD,IAAI,CAAC,WAAW,EAAC,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAc/C,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAYtD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAWtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAW3B,eAAe;IAIT,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAWrB,SAAS,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;YAI/B,OAAO;YA2BP,aAAa;YAeb,IAAI;CAwBrB"}
|
package/lib/src/stmt/wsStmt.js
CHANGED
|
@@ -24,7 +24,7 @@ class WsStmt {
|
|
|
24
24
|
return await wsStmt.init(reqId);
|
|
25
25
|
}
|
|
26
26
|
catch (e) {
|
|
27
|
-
log_1.default.error(e.code, e.message);
|
|
27
|
+
log_1.default.error(`WsStmt init is failed, ${e.code}, ${e.message}`);
|
|
28
28
|
throw (e);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -109,12 +109,6 @@ class WsStmt {
|
|
|
109
109
|
};
|
|
110
110
|
return await this.execute(queryMsg);
|
|
111
111
|
}
|
|
112
|
-
/**
|
|
113
|
-
* return client version.
|
|
114
|
-
*/
|
|
115
|
-
async version() {
|
|
116
|
-
return await this._wsClient.version();
|
|
117
|
-
}
|
|
118
112
|
async exec() {
|
|
119
113
|
let queryMsg = {
|
|
120
114
|
action: 'exec',
|
|
@@ -186,6 +180,7 @@ class WsStmt {
|
|
|
186
180
|
try {
|
|
187
181
|
if (this._wsClient.getState() <= 0) {
|
|
188
182
|
await this._wsClient.connect();
|
|
183
|
+
await this._wsClient.checkVersion();
|
|
189
184
|
}
|
|
190
185
|
let queryMsg = {
|
|
191
186
|
action: 'init',
|
|
@@ -197,7 +192,7 @@ class WsStmt {
|
|
|
197
192
|
return this;
|
|
198
193
|
}
|
|
199
194
|
catch (e) {
|
|
200
|
-
log_1.default.error(e.code, e.message);
|
|
195
|
+
log_1.default.error(`stmt init filed, ${e.code}, ${e.message}`);
|
|
201
196
|
throw (e);
|
|
202
197
|
}
|
|
203
198
|
}
|
package/lib/src/tmq/config.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
export declare class TmqConfig {
|
|
2
|
-
url: URL;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
url: URL | null;
|
|
3
|
+
sql_url: URL | null;
|
|
4
|
+
user: string | null;
|
|
5
|
+
password: string | null;
|
|
6
|
+
group_id: string | null;
|
|
7
|
+
client_id: string | null;
|
|
8
|
+
offset_rest: string | null;
|
|
8
9
|
topics?: Array<string>;
|
|
9
10
|
auto_commit: boolean;
|
|
10
11
|
auto_commit_interval_ms: number;
|
|
11
12
|
timeout: number;
|
|
13
|
+
otherConfigs: Map<string, any>;
|
|
12
14
|
constructor(wsConfig: Map<string, any>);
|
|
13
15
|
}
|
|
14
16
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/tmq/config.ts"],"names":[],"mappings":"AAEA,qBAAa,SAAS;IAElB,GAAG,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/tmq/config.ts"],"names":[],"mappings":"AAEA,qBAAa,SAAS;IAElB,GAAG,EAAE,GAAG,GAAG,IAAI,CAAQ;IACvB,OAAO,EAAE,GAAG,GAAG,IAAI,CAAQ;IAC3B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC3B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC/B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC/B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAQ;IAChC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAQ;IAClC,MAAM,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,WAAW,EAAE,OAAO,CAAS;IAC7B,uBAAuB,EAAE,MAAM,CAAY;IAC3C,OAAO,EAAE,MAAM,CAAQ;IACvB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;gBAGnB,QAAQ,EAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC;CAyDxC"}
|
package/lib/src/tmq/config.js
CHANGED
|
@@ -4,23 +4,50 @@ exports.TmqConfig = void 0;
|
|
|
4
4
|
const constant_1 = require("./constant");
|
|
5
5
|
class TmqConfig {
|
|
6
6
|
constructor(wsConfig) {
|
|
7
|
-
|
|
8
|
-
this.
|
|
9
|
-
this.
|
|
10
|
-
this.
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
this.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
7
|
+
// req_id: number;
|
|
8
|
+
this.url = null;
|
|
9
|
+
this.sql_url = null;
|
|
10
|
+
this.user = null;
|
|
11
|
+
this.password = null;
|
|
12
|
+
this.group_id = null;
|
|
13
|
+
this.client_id = null;
|
|
14
|
+
this.offset_rest = null;
|
|
15
|
+
this.auto_commit = false;
|
|
16
|
+
this.auto_commit_interval_ms = 5 * 1000;
|
|
17
|
+
this.timeout = 5000;
|
|
18
|
+
this.otherConfigs = new Map();
|
|
19
|
+
for (const [key, value] of wsConfig) {
|
|
20
|
+
switch (key) {
|
|
21
|
+
case constant_1.TMQConstants.WS_URL:
|
|
22
|
+
this.url = new URL(value);
|
|
23
|
+
break;
|
|
24
|
+
case constant_1.TMQConstants.CONNECT_USER:
|
|
25
|
+
this.user = value;
|
|
26
|
+
break;
|
|
27
|
+
case constant_1.TMQConstants.CONNECT_PASS:
|
|
28
|
+
this.password = value;
|
|
29
|
+
break;
|
|
30
|
+
case constant_1.TMQConstants.GROUP_ID:
|
|
31
|
+
this.group_id = value;
|
|
32
|
+
break;
|
|
33
|
+
case constant_1.TMQConstants.CLIENT_ID:
|
|
34
|
+
this.client_id = value;
|
|
35
|
+
break;
|
|
36
|
+
case constant_1.TMQConstants.AUTO_OFFSET_RESET:
|
|
37
|
+
this.offset_rest = value;
|
|
38
|
+
break;
|
|
39
|
+
case constant_1.TMQConstants.ENABLE_AUTO_COMMIT:
|
|
40
|
+
this.auto_commit = value;
|
|
41
|
+
break;
|
|
42
|
+
case constant_1.TMQConstants.AUTO_COMMIT_INTERVAL_MS:
|
|
43
|
+
this.auto_commit_interval_ms = value;
|
|
44
|
+
break;
|
|
45
|
+
case constant_1.TMQConstants.CONNECT_MESSAGE_TIMEOUT:
|
|
46
|
+
this.timeout = value;
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
this.otherConfigs.set(key, value);
|
|
50
|
+
}
|
|
24
51
|
}
|
|
25
52
|
if (this.url) {
|
|
26
53
|
if (this.user) {
|
|
@@ -35,6 +62,8 @@ class TmqConfig {
|
|
|
35
62
|
else {
|
|
36
63
|
this.password = this.url.password;
|
|
37
64
|
}
|
|
65
|
+
this.sql_url = new URL(this.url);
|
|
66
|
+
this.sql_url.pathname = '/ws';
|
|
38
67
|
this.url.pathname = '/rest/tmq';
|
|
39
68
|
}
|
|
40
69
|
}
|