@tdengine/websocket 3.1.7 → 3.1.9
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/src/client/wsClient.d.ts +3 -0
- package/lib/src/client/wsClient.d.ts.map +1 -1
- package/lib/src/client/wsClient.js +39 -14
- package/lib/src/client/wsConnector.d.ts.map +1 -1
- package/lib/src/client/wsConnector.js +4 -10
- package/lib/src/client/wsConnectorPool.d.ts.map +1 -1
- package/lib/src/client/wsConnectorPool.js +16 -5
- package/lib/src/client/wsResponse.d.ts +2 -16
- package/lib/src/client/wsResponse.d.ts.map +1 -1
- package/lib/src/client/wsResponse.js +3 -11
- package/lib/src/common/config.d.ts +3 -0
- package/lib/src/common/config.d.ts.map +1 -1
- package/lib/src/common/config.js +6 -0
- package/lib/src/common/constant.d.ts +9 -1
- package/lib/src/common/constant.d.ts.map +1 -1
- package/lib/src/common/constant.js +10 -1
- package/lib/src/common/taosResult.d.ts +5 -2
- package/lib/src/common/taosResult.d.ts.map +1 -1
- package/lib/src/common/taosResult.js +59 -5
- package/lib/src/common/utils.d.ts +1 -0
- package/lib/src/common/utils.d.ts.map +1 -1
- package/lib/src/common/utils.js +31 -0
- package/lib/src/sql/wsRows.d.ts.map +1 -1
- package/lib/src/sql/wsRows.js +10 -4
- package/lib/src/sql/wsSql.d.ts.map +1 -1
- package/lib/src/sql/wsSql.js +12 -2
- package/lib/src/stmt/wsProto.d.ts +3 -3
- package/lib/src/stmt/wsProto.js +2 -2
- package/lib/src/stmt/wsStmt.d.ts +1 -1
- package/lib/src/stmt/wsStmt.d.ts.map +1 -1
- package/lib/src/stmt/wsStmt.js +2 -1
- package/lib/src/tmq/config.d.ts.map +1 -1
- package/lib/src/tmq/config.js +1 -1
- package/lib/src/tmq/constant.d.ts +2 -0
- package/lib/src/tmq/constant.d.ts.map +1 -1
- package/lib/src/tmq/constant.js +2 -0
- package/lib/src/tmq/tmqResponse.d.ts +5 -5
- package/lib/src/tmq/tmqResponse.js +7 -7
- package/lib/src/tmq/wsTmq.d.ts +1 -0
- package/lib/src/tmq/wsTmq.d.ts.map +1 -1
- package/lib/src/tmq/wsTmq.js +9 -5
- package/lib/test/bulkPulling/cloud.tmq.test.d.ts +2 -0
- package/lib/test/bulkPulling/cloud.tmq.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/cloud.tmq.test.js +79 -0
- package/lib/test/bulkPulling/decimal.test.d.ts +2 -0
- package/lib/test/bulkPulling/decimal.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/decimal.test.js +129 -0
- package/lib/test/bulkPulling/sql.test.js +36 -10
- package/lib/test/bulkPulling/stmt.func.test.js +2 -0
- package/lib/test/bulkPulling/stmt.type.test.js +41 -0
- package/lib/test/bulkPulling/tmq.test.js +2 -0
- package/lib/test/bulkPulling/wsConnectPool.test.js +2 -2
- package/package.json +2 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsRows.d.ts","sourceRoot":"","sources":["../../../src/sql/wsRows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA0B,MAAM,sBAAsB,CAAC;AAE5E,OAAO,EAAwB,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAM9C,qBAAa,MAAM;IACf,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAkB;IACnD,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,QAAQ,CAAW;gBAEf,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe;IAOlD,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;YAoBhB,YAAY;
|
|
1
|
+
{"version":3,"file":"wsRows.d.ts","sourceRoot":"","sources":["../../../src/sql/wsRows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA0B,MAAM,sBAAsB,CAAC;AAE5E,OAAO,EAAwB,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAM9C,qBAAa,MAAM;IACf,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAkB;IACnD,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,QAAQ,CAAW;gBAEf,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe;IAOlD,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;YAoBhB,YAAY;IAiC1B,OAAO,IAAG,KAAK,CAAC,YAAY,CAAC,GAAG,IAAI;IAIpC,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS;IAc3B,KAAK,IAAG,OAAO,CAAC,IAAI,CAAC;CAQ9B"}
|
package/lib/src/sql/wsRows.js
CHANGED
|
@@ -20,7 +20,7 @@ class WSRows {
|
|
|
20
20
|
}
|
|
21
21
|
async next() {
|
|
22
22
|
if (this._wsQueryResponse.is_update || this._isClose) {
|
|
23
|
-
log_1.default.debug(
|
|
23
|
+
log_1.default.debug(`WSRows::Next::End=> ${this._taosResult}, ${this._isClose}`);
|
|
24
24
|
return false;
|
|
25
25
|
}
|
|
26
26
|
let data = this._taosResult.getData();
|
|
@@ -43,7 +43,8 @@ class WSRows {
|
|
|
43
43
|
this._taosResult.addTotalTime(resp.totalTime);
|
|
44
44
|
let wsResponse = new wsResponse_1.WSFetchBlockResponse(resp.msg);
|
|
45
45
|
if (wsResponse.code != 0) {
|
|
46
|
-
|
|
46
|
+
await this.close();
|
|
47
|
+
log_1.default.error(`Executing SQL statement returns error: ${wsResponse.code}, ${wsResponse.message}`);
|
|
47
48
|
throw new wsError_1.TaosResultError(wsResponse.code, wsResponse.message);
|
|
48
49
|
}
|
|
49
50
|
if (wsResponse.finished == 1) {
|
|
@@ -57,7 +58,12 @@ class WSRows {
|
|
|
57
58
|
return this._taosResult;
|
|
58
59
|
}
|
|
59
60
|
catch (err) {
|
|
60
|
-
|
|
61
|
+
try {
|
|
62
|
+
await this.close();
|
|
63
|
+
}
|
|
64
|
+
catch (closeErr) {
|
|
65
|
+
log_1.default.error(`GetBlockData encountered an exception while calling the close method, reason: ${closeErr.message}`);
|
|
66
|
+
}
|
|
61
67
|
throw new wsError_1.TaosResultError(err.code, err.message);
|
|
62
68
|
}
|
|
63
69
|
}
|
|
@@ -81,7 +87,7 @@ class WSRows {
|
|
|
81
87
|
return;
|
|
82
88
|
}
|
|
83
89
|
this._isClose = true;
|
|
84
|
-
this._wsClient.freeResult(this._wsQueryResponse);
|
|
90
|
+
await this._wsClient.freeResult(this._wsQueryResponse);
|
|
85
91
|
}
|
|
86
92
|
}
|
|
87
93
|
exports.WSRows = WSRows;
|
|
@@ -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;IAgCnD,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
|
@@ -32,6 +32,16 @@ class WsSql {
|
|
|
32
32
|
if (database && database.length > 0) {
|
|
33
33
|
await wsSql.exec(`use ${database}`);
|
|
34
34
|
}
|
|
35
|
+
else {
|
|
36
|
+
await wsSql.exec('use information_schema');
|
|
37
|
+
}
|
|
38
|
+
let timezone = wsConfig.getTimezone();
|
|
39
|
+
if (timezone && timezone.length > 0) {
|
|
40
|
+
await wsSql._wsClient.setOptionConnection(constant_1.TSDB_OPTION_CONNECTION.TSDB_OPTION_CONNECTION_TIMEZONE, timezone);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
await wsSql._wsClient.setOptionConnection(constant_1.TSDB_OPTION_CONNECTION.TSDB_OPTION_CONNECTION_TIMEZONE, null);
|
|
44
|
+
}
|
|
35
45
|
return wsSql;
|
|
36
46
|
}
|
|
37
47
|
catch (e) {
|
|
@@ -115,7 +125,7 @@ class WsSql {
|
|
|
115
125
|
taosResult.addTotalTime(resp.totalTime);
|
|
116
126
|
let wsResponse = new wsResponse_1.WSFetchBlockResponse(resp.msg);
|
|
117
127
|
if (wsResponse.code != 0) {
|
|
118
|
-
log_1.default.error(
|
|
128
|
+
log_1.default.error(`Executing SQL statement returns error: ${wsResponse.code}, ${wsResponse.message}`);
|
|
119
129
|
throw new wsError_1.TaosResultError(wsResponse.code, wsResponse.message);
|
|
120
130
|
}
|
|
121
131
|
if (wsResponse.finished == 1) {
|
|
@@ -129,7 +139,7 @@ class WsSql {
|
|
|
129
139
|
throw new wsError_1.TaosResultError(err.code, err.message);
|
|
130
140
|
}
|
|
131
141
|
finally {
|
|
132
|
-
this._wsClient.freeResult(wsQueryResponse);
|
|
142
|
+
await this._wsClient.freeResult(wsQueryResponse);
|
|
133
143
|
}
|
|
134
144
|
}
|
|
135
145
|
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_FETCH_MESSAGE_DATA, "The result data of the query is incorrect");
|
|
@@ -8,20 +8,20 @@ export interface StmtMessageInfo {
|
|
|
8
8
|
interface StmtParamsInfo {
|
|
9
9
|
req_id: number;
|
|
10
10
|
sql?: string | undefined | null;
|
|
11
|
-
stmt_id?:
|
|
11
|
+
stmt_id?: bigint | undefined | null;
|
|
12
12
|
name?: string | undefined | null;
|
|
13
13
|
tags?: Array<any> | undefined | null;
|
|
14
14
|
paramArray?: Array<Array<any>> | undefined | null;
|
|
15
15
|
}
|
|
16
16
|
export declare class WsStmtQueryResponse extends WSQueryResponse {
|
|
17
17
|
affected: number | undefined | null;
|
|
18
|
-
stmt_id?:
|
|
18
|
+
stmt_id?: bigint | undefined | null;
|
|
19
19
|
constructor(resp: MessageResp);
|
|
20
20
|
}
|
|
21
21
|
export declare const enum StmtBindType {
|
|
22
22
|
STMT_TYPE_TAG = 1,
|
|
23
23
|
STMT_TYPE_BIND = 2
|
|
24
24
|
}
|
|
25
|
-
export declare function binaryBlockEncode(bindParams: StmtBindParams, bindType: StmtBindType, stmtId:
|
|
25
|
+
export declare function binaryBlockEncode(bindParams: StmtBindParams, bindType: StmtBindType, stmtId: bigint, reqId: bigint, row: number): ArrayBuffer;
|
|
26
26
|
export {};
|
|
27
27
|
//# sourceMappingURL=wsProto.d.ts.map
|
package/lib/src/stmt/wsProto.js
CHANGED
|
@@ -7,7 +7,7 @@ const constant_1 = require("../common/constant");
|
|
|
7
7
|
class WsStmtQueryResponse extends wsResponse_1.WSQueryResponse {
|
|
8
8
|
constructor(resp) {
|
|
9
9
|
super(resp);
|
|
10
|
-
this.stmt_id = resp.msg.stmt_id;
|
|
10
|
+
this.stmt_id = BigInt(resp.msg.stmt_id);
|
|
11
11
|
this.affected = resp.msg.affected;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -22,7 +22,7 @@ function binaryBlockEncode(bindParams, bindType, stmtId, reqId, row) {
|
|
|
22
22
|
let arrayBuffer = new ArrayBuffer(length);
|
|
23
23
|
let arrayView = new DataView(arrayBuffer);
|
|
24
24
|
arrayView.setBigUint64(0, reqId, true);
|
|
25
|
-
arrayView.setBigUint64(8,
|
|
25
|
+
arrayView.setBigUint64(8, stmtId, true);
|
|
26
26
|
arrayView.setBigUint64(16, BigInt(bindType), true);
|
|
27
27
|
//version int32
|
|
28
28
|
arrayView.setUint32(24, 1, true);
|
package/lib/src/stmt/wsStmt.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare class WsStmt {
|
|
|
18
18
|
exec(): Promise<void>;
|
|
19
19
|
getLastAffected(): number | null | undefined;
|
|
20
20
|
close(): Promise<void>;
|
|
21
|
-
getStmtId():
|
|
21
|
+
getStmtId(): bigint | undefined | null;
|
|
22
22
|
private execute;
|
|
23
23
|
private sendBinaryMsg;
|
|
24
24
|
private init;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsStmt.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsStmt.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wsStmt.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsStmt.ts"],"names":[],"mappings":"AACA,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
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.WsStmt = void 0;
|
|
7
|
+
const json_bigint_1 = __importDefault(require("json-bigint"));
|
|
7
8
|
const wsError_1 = require("../common/wsError");
|
|
8
9
|
const wsProto_1 = require("./wsProto");
|
|
9
10
|
const reqid_1 = require("../common/reqid");
|
|
@@ -140,7 +141,7 @@ class WsStmt {
|
|
|
140
141
|
if (this._wsClient.getState() <= 0) {
|
|
141
142
|
throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_CONNECTION_CLOSED, "websocket connect has closed!");
|
|
142
143
|
}
|
|
143
|
-
let reqMsg =
|
|
144
|
+
let reqMsg = json_bigint_1.default.stringify(queryMsg);
|
|
144
145
|
if (register) {
|
|
145
146
|
let result = await this._wsClient.exec(reqMsg, false);
|
|
146
147
|
let resp = new wsProto_1.WsStmtQueryResponse(result);
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,CAAQ;IAC5B,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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../src/tmq/constant.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAY;IACrB,OAAc,QAAQ,EAAE,MAAM,CAAc;IAE5C,OAAc,SAAS,EAAE,MAAM,CAAe;IAE9C;;OAEG;IACH,OAAc,kBAAkB,EAAE,MAAM,CAAwB;IAEhE;;OAEG;IACH,OAAc,uBAAuB,EAAE,MAAM,CAA6B;IAE1E;;OAEG;IACH,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IACpC,OAAc,YAAY,EAAE,MAAM,CAAmB;IACrD,OAAc,SAAS,EAAE,MAAM,CAAe;IAC9C,OAAc,QAAQ,EAAE,MAAM,CAAc;IAC5C,OAAc,UAAU,EAAE,MAAM,CAAiB;IACjD,OAAc,WAAW,EAAE,MAAM,CAAK;CACzC;AAED,qBAAa,YAAY;IACrB,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAG,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;;CAItB;AAED,qBAAa,gBAAgB;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAI,MAAM,CAAC;IACf,KAAK,EAAG,MAAM,CAAC;IACf,KAAK,EAAG,MAAM,CAAA;IACd,IAAI,EAAG,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;;CAWjB"}
|
package/lib/src/tmq/constant.js
CHANGED
|
@@ -10,7 +10,7 @@ export declare class WsPollResponse {
|
|
|
10
10
|
topic: string;
|
|
11
11
|
database: string;
|
|
12
12
|
vgroup_id: number;
|
|
13
|
-
message_id:
|
|
13
|
+
message_id: bigint;
|
|
14
14
|
id: bigint;
|
|
15
15
|
message_type: number;
|
|
16
16
|
totalTime: number;
|
|
@@ -74,7 +74,7 @@ export declare class PartitionsResp {
|
|
|
74
74
|
action: string;
|
|
75
75
|
totalTime: number;
|
|
76
76
|
timing: bigint;
|
|
77
|
-
positions:
|
|
77
|
+
positions: bigint[];
|
|
78
78
|
constructor(resp: MessageResp);
|
|
79
79
|
setTopicPartitions(topicPartitions: TopicPartition[]): TopicPartition[];
|
|
80
80
|
}
|
|
@@ -84,9 +84,9 @@ export declare class CommittedResp extends PartitionsResp {
|
|
|
84
84
|
export declare class TopicPartition {
|
|
85
85
|
topic: string;
|
|
86
86
|
vgroup_id: number;
|
|
87
|
-
offset?:
|
|
88
|
-
begin?:
|
|
89
|
-
end?:
|
|
87
|
+
offset?: bigint;
|
|
88
|
+
begin?: bigint;
|
|
89
|
+
end?: bigint;
|
|
90
90
|
constructor(msg: any);
|
|
91
91
|
}
|
|
92
92
|
//# sourceMappingURL=tmqResponse.d.ts.map
|
|
@@ -22,7 +22,7 @@ class WsPollResponse {
|
|
|
22
22
|
this.topic = resp.msg.topic;
|
|
23
23
|
this.database = resp.msg.database;
|
|
24
24
|
this.vgroup_id = resp.msg.vgroup_id;
|
|
25
|
-
this.message_id = resp.msg.message_id;
|
|
25
|
+
this.message_id = BigInt(resp.msg.message_id);
|
|
26
26
|
this.message_type = resp.msg.message_type;
|
|
27
27
|
if (resp.msg.id) {
|
|
28
28
|
this.id = BigInt(resp.msg.id);
|
|
@@ -209,7 +209,7 @@ class WSTmqFetchBlockInfo {
|
|
|
209
209
|
let bitMapArr = new Uint8Array(dataView.buffer, dataView.byteOffset + bufferOffset, bitMapOffset);
|
|
210
210
|
bufferOffset += bitMapOffset;
|
|
211
211
|
//decode column data, data is array
|
|
212
|
-
data = (0, taosResult_1.readSolidDataToArray)(dataView, bufferOffset, rows, this.schema[i].colType, bitMapArr);
|
|
212
|
+
data = (0, taosResult_1.readSolidDataToArray)(dataView, bufferOffset, rows, this.schema[i].colType, bitMapArr, startOffset, i);
|
|
213
213
|
}
|
|
214
214
|
else {
|
|
215
215
|
//Variable length type
|
|
@@ -294,7 +294,7 @@ class PartitionsResp {
|
|
|
294
294
|
this.req_id = resp.msg.req_id;
|
|
295
295
|
this.action = resp.msg.action;
|
|
296
296
|
this.totalTime = resp.totalTime;
|
|
297
|
-
this.positions = resp.msg.position;
|
|
297
|
+
this.positions = resp.msg.position ? resp.msg.position.map((pos) => BigInt(pos)) : [];
|
|
298
298
|
}
|
|
299
299
|
setTopicPartitions(topicPartitions) {
|
|
300
300
|
if (topicPartitions.length != this.positions.length) {
|
|
@@ -310,16 +310,16 @@ exports.PartitionsResp = PartitionsResp;
|
|
|
310
310
|
class CommittedResp extends PartitionsResp {
|
|
311
311
|
constructor(resp) {
|
|
312
312
|
super(resp);
|
|
313
|
-
this.positions = resp.msg.committed;
|
|
313
|
+
this.positions = resp.msg.committed ? resp.msg.committed.map((pos) => BigInt(pos)) : [];
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
316
|
exports.CommittedResp = CommittedResp;
|
|
317
317
|
class TopicPartition {
|
|
318
318
|
constructor(msg) {
|
|
319
319
|
this.vgroup_id = msg.vgroup_id;
|
|
320
|
-
this.offset = msg.offset;
|
|
321
|
-
this.begin = msg.begin;
|
|
322
|
-
this.end = msg.end;
|
|
320
|
+
this.offset = BigInt(msg.offset);
|
|
321
|
+
this.begin = BigInt(msg.begin);
|
|
322
|
+
this.end = BigInt(msg.end);
|
|
323
323
|
this.topic = '';
|
|
324
324
|
}
|
|
325
325
|
}
|
package/lib/src/tmq/wsTmq.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsTmq.d.ts","sourceRoot":"","sources":["../../../src/tmq/wsTmq.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wsTmq.d.ts","sourceRoot":"","sources":["../../../src/tmq/wsTmq.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAkF,cAAc,EAA0D,MAAM,eAAe,CAAC;AAKvL,qBAAa,UAAU;IACnB,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,OAAO,CAAC,CAAU;IAC1B,OAAO,CAAC,WAAW,CAAC,CAAQ;IAC5B,OAAO,CAAC,cAAc,CAAC,CAAQ;IAC/B,OAAO;YAWO,IAAI;WAuBL,WAAW,CAAC,QAAQ,EAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAE,OAAO,CAAC,UAAU,CAAC;IAUjE,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,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,CAAC,IAAI,CAAC;YAIb,cAAc;YAuBd,QAAQ;YA6BR,iBAAiB;IAczB,UAAU,CAAC,MAAM,CAAC,EAAC,MAAM,EAAE,GAAE,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;YAoBnD,gBAAgB;CA6BjC"}
|
package/lib/src/tmq/wsTmq.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.WsConsumer = void 0;
|
|
7
|
+
const json_bigint_1 = __importDefault(require("json-bigint"));
|
|
7
8
|
const config_1 = require("./config");
|
|
8
9
|
const constant_1 = require("./constant");
|
|
9
10
|
const wsClient_1 = require("../client/wsClient");
|
|
@@ -20,6 +21,7 @@ class WsConsumer {
|
|
|
20
21
|
throw new wsError_1.WebSocketInterfaceError(wsError_1.ErrorCode.ERR_INVALID_URL, 'invalid url, password or username needed.');
|
|
21
22
|
}
|
|
22
23
|
this._wsClient = new wsClient_1.WsClient(this._wsConfig.url, this._wsConfig.timeout);
|
|
24
|
+
this._lastMessageID = BigInt(0);
|
|
23
25
|
}
|
|
24
26
|
async init() {
|
|
25
27
|
let wsSql = null;
|
|
@@ -142,7 +144,7 @@ class WsConsumer {
|
|
|
142
144
|
topic_vgroup_ids: offsets
|
|
143
145
|
},
|
|
144
146
|
};
|
|
145
|
-
let resp = await this._wsClient.exec(
|
|
147
|
+
let resp = await this._wsClient.exec(json_bigint_1.default.stringify(queryMsg), false);
|
|
146
148
|
return new tmqResponse_1.CommittedResp(resp).setTopicPartitions(offsets);
|
|
147
149
|
}
|
|
148
150
|
async commitOffsets(partitions) {
|
|
@@ -169,7 +171,7 @@ class WsConsumer {
|
|
|
169
171
|
offset: partition.offset,
|
|
170
172
|
},
|
|
171
173
|
};
|
|
172
|
-
return await this._wsClient.exec(
|
|
174
|
+
return await this._wsClient.exec(json_bigint_1.default.stringify(queryMsg));
|
|
173
175
|
}
|
|
174
176
|
async positions(partitions, reqId) {
|
|
175
177
|
if (!partitions || partitions.length == 0) {
|
|
@@ -231,7 +233,7 @@ class WsConsumer {
|
|
|
231
233
|
message_id: pollResp.message_id,
|
|
232
234
|
},
|
|
233
235
|
};
|
|
234
|
-
let jsonStr =
|
|
236
|
+
let jsonStr = json_bigint_1.default.stringify(fetchMsg);
|
|
235
237
|
log_1.default.debug('[wsQueryInterface.fetch.fetchMsg]===>' + jsonStr);
|
|
236
238
|
let result = await this._wsClient.sendMsg(jsonStr);
|
|
237
239
|
let wsResponse = new wsResponse_1.WSFetchBlockResponse(result.msg);
|
|
@@ -249,10 +251,11 @@ class WsConsumer {
|
|
|
249
251
|
action: constant_1.TMQMessageType.Poll,
|
|
250
252
|
args: {
|
|
251
253
|
req_id: reqid_1.ReqId.getReqID(reqId),
|
|
252
|
-
blocking_time: timeoutMs
|
|
254
|
+
blocking_time: timeoutMs,
|
|
255
|
+
message_id: this._lastMessageID,
|
|
253
256
|
},
|
|
254
257
|
};
|
|
255
|
-
let resp = await this._wsClient.exec(
|
|
258
|
+
let resp = await this._wsClient.exec(json_bigint_1.default.stringify(queryMsg), false);
|
|
256
259
|
let pollResp = new tmqResponse_1.WsPollResponse(resp);
|
|
257
260
|
let taosResult = new tmqResponse_1.TaosTmqResult(pollResp);
|
|
258
261
|
var taosResults = new Map();
|
|
@@ -260,6 +263,7 @@ class WsConsumer {
|
|
|
260
263
|
if (!pollResp.have_message || pollResp.message_type != constant_1.TMQMessageType.ResDataType) {
|
|
261
264
|
return taosResults;
|
|
262
265
|
}
|
|
266
|
+
this._lastMessageID = pollResp.message_id;
|
|
263
267
|
let finish = false;
|
|
264
268
|
while (!finish) {
|
|
265
269
|
finish = await this.fetchBlockData(pollResp, taosResult);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud.tmq.test.d.ts","sourceRoot":"","sources":["../../../test/bulkPulling/cloud.tmq.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constant_1 = require("../../src/tmq/constant");
|
|
4
|
+
const wsTmq_1 = require("../../src/tmq/wsTmq");
|
|
5
|
+
const wsConnectorPool_1 = require("../../src/client/wsConnectorPool");
|
|
6
|
+
const log_1 = require("../../src/common/log");
|
|
7
|
+
const config_1 = require("../../src/common/config");
|
|
8
|
+
const wsSql_1 = require("../../src/sql/wsSql");
|
|
9
|
+
beforeAll(async () => {
|
|
10
|
+
const url = `wss://${process.env.TDENGINE_CLOUD_URL}?token=${process.env.TDENGINE_CLOUD_TOKEN}`;
|
|
11
|
+
let wsSql = null;
|
|
12
|
+
try {
|
|
13
|
+
const conf = new config_1.WSConfig(url);
|
|
14
|
+
conf.setUser('root');
|
|
15
|
+
conf.setPwd('taosdata');
|
|
16
|
+
wsSql = await wsSql_1.WsSql.open(conf);
|
|
17
|
+
let sql = `INSERT INTO dmeters.d1001 USING dmeters.meters (groupid, location) TAGS(2, 'SanFrancisco')
|
|
18
|
+
VALUES (NOW + 1a, 10.30000, 219, 0.31000) (NOW + 2a, 12.60000, 218, 0.33000) (NOW + 3a, 12.30000, 221, 0.31000)
|
|
19
|
+
dmeters.d1002 USING dmeters.meters (groupid, location) TAGS(3, 'SanFrancisco')
|
|
20
|
+
VALUES (NOW + 1a, 10.30000, 218, 0.25000)`;
|
|
21
|
+
let res = await wsSql.exec(sql);
|
|
22
|
+
console.log(res);
|
|
23
|
+
expect(res.getAffectRows()).toBeGreaterThanOrEqual(3);
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
throw err;
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
if (wsSql) {
|
|
30
|
+
await wsSql.close();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
describe('TDWebSocket.Tmq()', () => {
|
|
35
|
+
jest.setTimeout(20 * 1000);
|
|
36
|
+
test('normal connect', async () => {
|
|
37
|
+
const url = `wss://${process.env.TDENGINE_CLOUD_URL}?token=${process.env.TDENGINE_CLOUD_TOKEN}`;
|
|
38
|
+
const topic = 'topic_meters';
|
|
39
|
+
const topics = [topic];
|
|
40
|
+
const groupId = 'group1';
|
|
41
|
+
const clientId = 'client1';
|
|
42
|
+
let configMap = new Map([
|
|
43
|
+
[constant_1.TMQConstants.GROUP_ID, groupId],
|
|
44
|
+
[constant_1.TMQConstants.CLIENT_ID, clientId],
|
|
45
|
+
[constant_1.TMQConstants.AUTO_OFFSET_RESET, 'earliest'],
|
|
46
|
+
[constant_1.TMQConstants.WS_URL, url],
|
|
47
|
+
[constant_1.TMQConstants.ENABLE_AUTO_COMMIT, 'true'],
|
|
48
|
+
[constant_1.TMQConstants.AUTO_COMMIT_INTERVAL_MS, '1000'],
|
|
49
|
+
]);
|
|
50
|
+
(0, log_1.setLevel)("debug");
|
|
51
|
+
// create consumer
|
|
52
|
+
let consumer = await wsTmq_1.WsConsumer.newConsumer(configMap);
|
|
53
|
+
console.log(`Create consumer successfully, host: ${url}, groupId: ${groupId}, clientId: ${clientId}`);
|
|
54
|
+
// subscribe
|
|
55
|
+
await consumer.subscribe(topics);
|
|
56
|
+
console.log(`Subscribe topics successfully, topics: ${topics}`);
|
|
57
|
+
let res = new Map();
|
|
58
|
+
while (res.size == 0) {
|
|
59
|
+
// poll
|
|
60
|
+
res = await consumer.poll(1000);
|
|
61
|
+
for (let [key, value] of res) {
|
|
62
|
+
// Add your data processing logic here
|
|
63
|
+
console.log(`data: ${key} ${value}`);
|
|
64
|
+
}
|
|
65
|
+
// commit
|
|
66
|
+
await consumer.commit();
|
|
67
|
+
}
|
|
68
|
+
// seek
|
|
69
|
+
let assignment = await consumer.assignment();
|
|
70
|
+
await consumer.seekToBeginning(assignment);
|
|
71
|
+
console.log('Assignment seek to beginning successfully');
|
|
72
|
+
// clean
|
|
73
|
+
await consumer.unsubscribe();
|
|
74
|
+
await consumer.close();
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
afterAll(async () => {
|
|
78
|
+
wsConnectorPool_1.WebSocketConnectionPool.instance().destroyed();
|
|
79
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decimal.test.d.ts","sourceRoot":"","sources":["../../../test/bulkPulling/decimal.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const wsConnectorPool_1 = require("../../src/client/wsConnectorPool");
|
|
4
|
+
const config_1 = require("../../src/common/config");
|
|
5
|
+
const wsSql_1 = require("../../src/sql/wsSql");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const log_1 = require("../../src/common/log");
|
|
8
|
+
const constant_1 = require("../../src/tmq/constant");
|
|
9
|
+
const wsTmq_1 = require("../../src/tmq/wsTmq");
|
|
10
|
+
let dns = 'ws://localhost:6041';
|
|
11
|
+
let createTopic = `create topic if not exists topic_decimal_test as select * from power.decimal_test`;
|
|
12
|
+
let dropTopic = `DROP TOPIC IF EXISTS topic_decimal_test;`;
|
|
13
|
+
(0, log_1.setLevel)("debug");
|
|
14
|
+
beforeAll(async () => {
|
|
15
|
+
let conf = new config_1.WSConfig(dns);
|
|
16
|
+
conf.setUser('root');
|
|
17
|
+
conf.setPwd('taosdata');
|
|
18
|
+
let wsSql = await wsSql_1.WsSql.open(conf);
|
|
19
|
+
await wsSql.exec(dropTopic);
|
|
20
|
+
await wsSql.exec('drop database if exists power');
|
|
21
|
+
await wsSql.exec('create database if not exists power KEEP 3650 DURATION 10 BUFFER 16 WAL_LEVEL 1;');
|
|
22
|
+
await (0, utils_1.Sleep)(100);
|
|
23
|
+
await wsSql.exec('use power');
|
|
24
|
+
await wsSql.exec('CREATE STABLE if not exists decimal_test (ts timestamp, dec64 decimal(10,6), dec128 decimal(24,10), int1 int) TAGS (location binary(64), groupId int);');
|
|
25
|
+
await wsSql.exec(createTopic);
|
|
26
|
+
await wsSql.close();
|
|
27
|
+
});
|
|
28
|
+
const expectedResultsMap = new Map([
|
|
29
|
+
['-1234.654321', { dec128: '-123456789012.0987654321', int1: 3, location: 'California', groupId: 3 }],
|
|
30
|
+
['-0.000654', { dec128: '-0.0009876543', int1: 2, location: 'California', groupId: 3 }],
|
|
31
|
+
['9876.123456', { dec128: '1234567890.0987654321', int1: 1, location: 'California', groupId: 3 }]
|
|
32
|
+
]);
|
|
33
|
+
describe('TDWebSocket.WsSql()', () => {
|
|
34
|
+
jest.setTimeout(20 * 1000);
|
|
35
|
+
test('insert recoder', async () => {
|
|
36
|
+
let conf = new config_1.WSConfig(dns);
|
|
37
|
+
conf.setUser('root');
|
|
38
|
+
conf.setPwd('taosdata');
|
|
39
|
+
let wsSql = await wsSql_1.WsSql.open(conf);
|
|
40
|
+
let taosResult = await wsSql.exec('use power');
|
|
41
|
+
console.log(taosResult);
|
|
42
|
+
expect(taosResult).toBeTruthy();
|
|
43
|
+
taosResult = await wsSql.exec('describe decimal_test');
|
|
44
|
+
console.log(taosResult);
|
|
45
|
+
taosResult = await wsSql.exec('INSERT INTO d1001 USING decimal_test (location, groupid) TAGS ("California", 3) VALUES (NOW, "9876.123456", "1234567890.0987654321", 1) (NOW + 1a, "-0.000654", "-0.0009876543", 2) (NOW + 2a, "-1234.654321", "-123456789012.0987654321", 3)');
|
|
46
|
+
console.log(taosResult);
|
|
47
|
+
expect(taosResult.getAffectRows()).toBeGreaterThanOrEqual(3);
|
|
48
|
+
let wsRows = await wsSql.query('select * from decimal_test');
|
|
49
|
+
expect(wsRows).toBeTruthy();
|
|
50
|
+
let meta = wsRows.getMeta();
|
|
51
|
+
expect(meta).toBeTruthy();
|
|
52
|
+
console.log("wsRow:meta:=>", meta);
|
|
53
|
+
let count = 0;
|
|
54
|
+
while (await wsRows.next()) {
|
|
55
|
+
let result = wsRows.getData();
|
|
56
|
+
if (result != null && result.length > 0) {
|
|
57
|
+
if (expectedResultsMap.has(result[1])) {
|
|
58
|
+
console.log("result:=>", result);
|
|
59
|
+
const expected = expectedResultsMap.get(result[1]);
|
|
60
|
+
expect(result[2]).toBe(expected?.dec128);
|
|
61
|
+
expect(result[3]).toBe(expected?.int1);
|
|
62
|
+
expect(result[4]).toBe(expected?.location);
|
|
63
|
+
expect(result[5]).toBe(expected?.groupId);
|
|
64
|
+
count++;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
await wsSql.close();
|
|
69
|
+
expect(count).toBe(3);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
test('normal Subscribe', async () => {
|
|
73
|
+
let configMap = new Map([
|
|
74
|
+
[constant_1.TMQConstants.GROUP_ID, "gId"],
|
|
75
|
+
[constant_1.TMQConstants.CONNECT_USER, "root"],
|
|
76
|
+
[constant_1.TMQConstants.CONNECT_PASS, "taosdata"],
|
|
77
|
+
[constant_1.TMQConstants.AUTO_OFFSET_RESET, "earliest"],
|
|
78
|
+
[constant_1.TMQConstants.CLIENT_ID, 'test_tmq_client'],
|
|
79
|
+
[constant_1.TMQConstants.WS_URL, dns],
|
|
80
|
+
[constant_1.TMQConstants.ENABLE_AUTO_COMMIT, 'true'],
|
|
81
|
+
[constant_1.TMQConstants.AUTO_COMMIT_INTERVAL_MS, '1000'],
|
|
82
|
+
["session.timeout.ms", "10000"],
|
|
83
|
+
["max.poll.interval.ms", "30000"],
|
|
84
|
+
["msg.with.table.name", "true"]
|
|
85
|
+
]);
|
|
86
|
+
let consumer = await wsTmq_1.WsConsumer.newConsumer(configMap);
|
|
87
|
+
await consumer.subscribe(['topic_decimal_test']);
|
|
88
|
+
let assignment = await consumer.assignment();
|
|
89
|
+
console.log(assignment);
|
|
90
|
+
let useTime = [];
|
|
91
|
+
let count = 0;
|
|
92
|
+
for (let i = 0; i < 5; i++) {
|
|
93
|
+
let startTime = new Date().getTime();
|
|
94
|
+
let res = await consumer.poll(500);
|
|
95
|
+
let currTime = new Date().getTime();
|
|
96
|
+
useTime.push(Math.abs(currTime - startTime));
|
|
97
|
+
for (let [key, value] of res) {
|
|
98
|
+
console.log(key, value.getMeta());
|
|
99
|
+
let data = value.getData();
|
|
100
|
+
if (data == null || data.length == 0) {
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
for (let record of data) {
|
|
104
|
+
console.log("record:=----------->", record);
|
|
105
|
+
if (expectedResultsMap.has(record[1])) {
|
|
106
|
+
const expected = expectedResultsMap.get(record[1]);
|
|
107
|
+
expect(record[2]).toBe(expected?.dec128);
|
|
108
|
+
expect(record[3]).toBe(expected?.int1);
|
|
109
|
+
expect(record[4]).toBe(expected?.location);
|
|
110
|
+
expect(record[5]).toBe(expected?.groupId);
|
|
111
|
+
count++;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
await consumer.unsubscribe();
|
|
117
|
+
await consumer.close();
|
|
118
|
+
expect(count).toBe(3);
|
|
119
|
+
});
|
|
120
|
+
afterAll(async () => {
|
|
121
|
+
let conf = new config_1.WSConfig(dns);
|
|
122
|
+
conf.setUser('root');
|
|
123
|
+
conf.setPwd('taosdata');
|
|
124
|
+
let wsSql = await wsSql_1.WsSql.open(conf);
|
|
125
|
+
await wsSql.exec(dropTopic);
|
|
126
|
+
await wsSql.exec('drop database power');
|
|
127
|
+
await wsSql.close();
|
|
128
|
+
wsConnectorPool_1.WebSocketConnectionPool.instance().destroyed();
|
|
129
|
+
});
|