@tdengine/websocket 3.1.9 → 3.2.1
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/all_type_query.js +26 -22
- package/lib/example/all_type_stmt.js +22 -20
- package/lib/example/basicBatchTmq.js +14 -14
- package/lib/example/basicSchemaless.js +11 -11
- package/lib/example/basicSql.js +10 -10
- package/lib/example/basicStmt.js +3 -3
- package/lib/example/basicTmq.js +8 -9
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/src/client/wsClient.d.ts +3 -2
- package/lib/src/client/wsClient.d.ts.map +1 -1
- package/lib/src/client/wsClient.js +66 -40
- package/lib/src/client/wsConnector.d.ts.map +1 -1
- package/lib/src/client/wsConnector.js +40 -14
- package/lib/src/client/wsConnectorPool.d.ts.map +1 -1
- package/lib/src/client/wsConnectorPool.js +29 -14
- package/lib/src/client/wsEventCallback.d.ts.map +1 -1
- package/lib/src/client/wsEventCallback.js +6 -4
- package/lib/src/client/wsResponse.d.ts.map +1 -1
- package/lib/src/client/wsResponse.js +6 -2
- package/lib/src/common/config.d.ts +5 -3
- package/lib/src/common/config.d.ts.map +1 -1
- package/lib/src/common/config.js +15 -5
- package/lib/src/common/constant.d.ts +11 -1
- package/lib/src/common/constant.d.ts.map +1 -1
- package/lib/src/common/constant.js +48 -40
- package/lib/src/common/log.d.ts +1 -1
- package/lib/src/common/log.d.ts.map +1 -1
- package/lib/src/common/log.js +9 -7
- package/lib/src/common/reqid.d.ts.map +1 -1
- package/lib/src/common/reqid.js +7 -7
- package/lib/src/common/taosResult.d.ts.map +1 -1
- package/lib/src/common/taosResult.js +46 -27
- package/lib/src/common/ut8Helper.d.ts.map +1 -1
- package/lib/src/common/ut8Helper.js +8 -8
- package/lib/src/common/utils.d.ts.map +1 -1
- package/lib/src/common/utils.js +17 -16
- package/lib/src/common/wsError.d.ts.map +1 -1
- package/lib/src/common/wsError.js +3 -3
- package/lib/src/common/wsOptions.d.ts +1 -1
- package/lib/src/index.d.ts +3 -3
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/sql/wsProto.d.ts.map +1 -1
- package/lib/src/sql/wsRows.d.ts +3 -3
- package/lib/src/sql/wsRows.d.ts.map +1 -1
- package/lib/src/sql/wsRows.js +4 -2
- package/lib/src/sql/wsSql.d.ts +5 -5
- package/lib/src/sql/wsSql.d.ts.map +1 -1
- package/lib/src/sql/wsSql.js +23 -15
- package/lib/src/stmt/FieldBindParams.d.ts +9 -0
- package/lib/src/stmt/FieldBindParams.d.ts.map +1 -0
- package/lib/src/stmt/FieldBindParams.js +13 -0
- package/lib/src/stmt/wsColumnInfo.d.ts +12 -0
- package/lib/src/stmt/wsColumnInfo.d.ts.map +1 -0
- package/lib/src/stmt/wsColumnInfo.js +17 -0
- package/lib/src/stmt/wsParams1.d.ts +14 -0
- package/lib/src/stmt/wsParams1.d.ts.map +1 -0
- package/lib/src/stmt/wsParams1.js +300 -0
- package/lib/src/stmt/wsParams2.d.ts +14 -0
- package/lib/src/stmt/wsParams2.d.ts.map +1 -0
- package/lib/src/stmt/wsParams2.js +203 -0
- package/lib/src/stmt/wsParamsBase.d.ts +45 -0
- package/lib/src/stmt/wsParamsBase.d.ts.map +1 -0
- package/lib/src/stmt/wsParamsBase.js +220 -0
- package/lib/src/stmt/wsProto.d.ts +13 -1
- package/lib/src/stmt/wsProto.d.ts.map +1 -1
- package/lib/src/stmt/wsProto.js +206 -2
- package/lib/src/stmt/wsStmt.d.ts +6 -16
- package/lib/src/stmt/wsStmt.d.ts.map +1 -1
- package/lib/src/stmt/wsStmt.js +0 -201
- package/lib/src/stmt/wsStmt1.d.ts +30 -0
- package/lib/src/stmt/wsStmt1.d.ts.map +1 -0
- package/lib/src/stmt/wsStmt1.js +206 -0
- package/lib/src/stmt/wsStmt2.d.ts +37 -0
- package/lib/src/stmt/wsStmt2.d.ts.map +1 -0
- package/lib/src/stmt/wsStmt2.js +284 -0
- package/lib/src/stmt/wsTableInfo.d.ts +17 -0
- package/lib/src/stmt/wsTableInfo.d.ts.map +1 -0
- package/lib/src/stmt/wsTableInfo.js +54 -0
- package/lib/src/tmq/config.d.ts.map +1 -1
- package/lib/src/tmq/config.js +2 -2
- package/lib/src/tmq/constant.d.ts.map +1 -1
- package/lib/src/tmq/constant.js +28 -28
- package/lib/src/tmq/tmqResponse.d.ts.map +1 -1
- package/lib/src/tmq/tmqResponse.js +31 -17
- package/lib/src/tmq/wsTmq.d.ts +2 -2
- package/lib/src/tmq/wsTmq.d.ts.map +1 -1
- package/lib/src/tmq/wsTmq.js +32 -30
- package/lib/test/bulkPulling/cloud.tmq.test.js +11 -11
- package/lib/test/bulkPulling/decimal.test.js +50 -26
- package/lib/test/bulkPulling/log.test.js +8 -8
- package/lib/test/bulkPulling/queryTables.test.js +255 -49
- package/lib/test/bulkPulling/schemaless.test.js +34 -34
- package/lib/test/bulkPulling/sql.test.js +108 -66
- package/lib/test/bulkPulling/stmt1.func.test.d.ts +2 -0
- package/lib/test/bulkPulling/stmt1.func.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/{stmt.func.test.js → stmt1.func.test.js} +128 -116
- package/lib/test/bulkPulling/stmt1.type.test.d.ts +2 -0
- package/lib/test/bulkPulling/stmt1.type.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/stmt1.type.test.js +399 -0
- package/lib/test/bulkPulling/stmt2.func.test.d.ts +2 -0
- package/lib/test/bulkPulling/stmt2.func.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/stmt2.func.test.js +543 -0
- package/lib/test/bulkPulling/stmt2.type.test.d.ts +2 -0
- package/lib/test/bulkPulling/stmt2.type.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/{stmt.type.test.js → stmt2.type.test.js} +136 -49
- package/lib/test/bulkPulling/tmq.test.js +225 -31
- package/lib/test/bulkPulling/utils.test.js +2 -2
- package/lib/test/bulkPulling/wsConnectPool.test.js +20 -20
- package/lib/test/utils.d.ts.map +1 -1
- package/lib/test/utils.js +130 -129
- package/package.json +1 -1
- package/readme.md +1 -0
- package/lib/src/stmt/wsParams.d.ts +0 -41
- package/lib/src/stmt/wsParams.d.ts.map +0 -1
- package/lib/src/stmt/wsParams.js +0 -428
- package/lib/test/bulkPulling/stmt.func.test.d.ts +0 -2
- package/lib/test/bulkPulling/stmt.func.test.d.ts.map +0 -1
- package/lib/test/bulkPulling/stmt.type.test.d.ts +0 -2
- package/lib/test/bulkPulling/stmt.type.test.d.ts.map +0 -1
package/lib/src/tmq/constant.js
CHANGED
|
@@ -4,87 +4,87 @@ exports.TMQRawDataSchema = exports.TMQBlockInfo = exports.TMQMessageType = expor
|
|
|
4
4
|
class TMQConstants {
|
|
5
5
|
}
|
|
6
6
|
exports.TMQConstants = TMQConstants;
|
|
7
|
-
TMQConstants.GROUP_ID =
|
|
8
|
-
TMQConstants.CLIENT_ID =
|
|
7
|
+
TMQConstants.GROUP_ID = "group.id";
|
|
8
|
+
TMQConstants.CLIENT_ID = "client.id";
|
|
9
9
|
/**
|
|
10
10
|
* auto commit default is true then the commitCallback function will be called after 5 seconds
|
|
11
11
|
*/
|
|
12
|
-
TMQConstants.ENABLE_AUTO_COMMIT =
|
|
12
|
+
TMQConstants.ENABLE_AUTO_COMMIT = "enable.auto.commit";
|
|
13
13
|
/**
|
|
14
14
|
* commit interval. unit milliseconds
|
|
15
15
|
*/
|
|
16
|
-
TMQConstants.AUTO_COMMIT_INTERVAL_MS =
|
|
16
|
+
TMQConstants.AUTO_COMMIT_INTERVAL_MS = "auto.commit.interval.ms";
|
|
17
17
|
/**
|
|
18
18
|
* only valid in first group id create.
|
|
19
19
|
*/
|
|
20
|
-
TMQConstants.AUTO_OFFSET_RESET =
|
|
20
|
+
TMQConstants.AUTO_OFFSET_RESET = "auto.offset.reset";
|
|
21
21
|
/**
|
|
22
22
|
* whether poll result include table name. suggest always true
|
|
23
23
|
*/
|
|
24
|
-
TMQConstants.MSG_WITH_TABLE_NAME =
|
|
24
|
+
TMQConstants.MSG_WITH_TABLE_NAME = "msg.with.table.name";
|
|
25
25
|
/**
|
|
26
26
|
* indicate host and port of connection
|
|
27
27
|
*/
|
|
28
|
-
TMQConstants.BOOTSTRAP_SERVERS =
|
|
28
|
+
TMQConstants.BOOTSTRAP_SERVERS = "bootstrap.servers";
|
|
29
29
|
/**
|
|
30
30
|
* deserializer Bean
|
|
31
31
|
*/
|
|
32
|
-
TMQConstants.VALUE_DESERIALIZER =
|
|
32
|
+
TMQConstants.VALUE_DESERIALIZER = "value.deserializer";
|
|
33
33
|
/**
|
|
34
34
|
* encode for deserializer String value
|
|
35
35
|
*/
|
|
36
|
-
TMQConstants.VALUE_DESERIALIZER_ENCODING =
|
|
36
|
+
TMQConstants.VALUE_DESERIALIZER_ENCODING = "value.deserializer.encoding";
|
|
37
37
|
/**
|
|
38
38
|
* connection ip
|
|
39
39
|
*/
|
|
40
|
-
TMQConstants.CONNECT_IP =
|
|
40
|
+
TMQConstants.CONNECT_IP = "td.connect.ip";
|
|
41
41
|
/**
|
|
42
42
|
* connection port
|
|
43
43
|
*/
|
|
44
|
-
TMQConstants.CONNECT_PORT =
|
|
44
|
+
TMQConstants.CONNECT_PORT = "td.connect.port";
|
|
45
45
|
/**
|
|
46
46
|
* connection username
|
|
47
47
|
*/
|
|
48
|
-
TMQConstants.CONNECT_USER =
|
|
48
|
+
TMQConstants.CONNECT_USER = "td.connect.user";
|
|
49
49
|
/**
|
|
50
50
|
* connection password
|
|
51
51
|
*/
|
|
52
|
-
TMQConstants.CONNECT_PASS =
|
|
52
|
+
TMQConstants.CONNECT_PASS = "td.connect.pass";
|
|
53
53
|
/**
|
|
54
54
|
* connect type websocket or jni, default is jni
|
|
55
55
|
*/
|
|
56
|
-
TMQConstants.CONNECT_TYPE =
|
|
56
|
+
TMQConstants.CONNECT_TYPE = "td.connect.type";
|
|
57
57
|
/**
|
|
58
58
|
* Key used to retrieve the token value from the properties instance passed to
|
|
59
59
|
* the driver.
|
|
60
60
|
* Just for Cloud Service
|
|
61
61
|
*/
|
|
62
|
-
TMQConstants.WS_URL =
|
|
62
|
+
TMQConstants.WS_URL = "ws.url";
|
|
63
63
|
/**
|
|
64
64
|
* the timeout in milliseconds until a connection is established.
|
|
65
65
|
* zero is interpreted as an infinite timeout.
|
|
66
66
|
* only valid in websocket
|
|
67
67
|
*/
|
|
68
|
-
TMQConstants.CONNECT_TIMEOUT =
|
|
68
|
+
TMQConstants.CONNECT_TIMEOUT = "httpConnectTimeout";
|
|
69
69
|
/**
|
|
70
70
|
* message receive from server timeout. ms.
|
|
71
71
|
* only valid in websocket
|
|
72
72
|
*/
|
|
73
|
-
TMQConstants.CONNECT_MESSAGE_TIMEOUT =
|
|
73
|
+
TMQConstants.CONNECT_MESSAGE_TIMEOUT = "messageWaitTimeout";
|
|
74
74
|
class TMQMessageType {
|
|
75
75
|
}
|
|
76
76
|
exports.TMQMessageType = TMQMessageType;
|
|
77
|
-
TMQMessageType.Subscribe =
|
|
78
|
-
TMQMessageType.Poll =
|
|
79
|
-
TMQMessageType.FetchRaw =
|
|
80
|
-
TMQMessageType.FetchJsonMeta =
|
|
81
|
-
TMQMessageType.Commit =
|
|
82
|
-
TMQMessageType.Unsubscribe =
|
|
83
|
-
TMQMessageType.GetTopicAssignment =
|
|
84
|
-
TMQMessageType.Seek =
|
|
85
|
-
TMQMessageType.CommitOffset =
|
|
86
|
-
TMQMessageType.Committed =
|
|
87
|
-
TMQMessageType.Position =
|
|
77
|
+
TMQMessageType.Subscribe = "subscribe";
|
|
78
|
+
TMQMessageType.Poll = "poll";
|
|
79
|
+
TMQMessageType.FetchRaw = "fetch_raw";
|
|
80
|
+
TMQMessageType.FetchJsonMeta = "fetch_json_meta";
|
|
81
|
+
TMQMessageType.Commit = "commit";
|
|
82
|
+
TMQMessageType.Unsubscribe = "unsubscribe";
|
|
83
|
+
TMQMessageType.GetTopicAssignment = "assignment";
|
|
84
|
+
TMQMessageType.Seek = "seek";
|
|
85
|
+
TMQMessageType.CommitOffset = "commit_offset";
|
|
86
|
+
TMQMessageType.Committed = "committed";
|
|
87
|
+
TMQMessageType.Position = "position";
|
|
88
88
|
TMQMessageType.ListTopics = "list_topics";
|
|
89
89
|
TMQMessageType.ResDataType = 1;
|
|
90
90
|
class TMQBlockInfo {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tmqResponse.d.ts","sourceRoot":"","sources":["../../../src/tmq/tmqResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"tmqResponse.d.ts","sourceRoot":"","sources":["../../../src/tmq/tmqResponse.ts"],"names":[],"mappings":"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"}
|
|
@@ -86,7 +86,7 @@ class WSTmqFetchBlockInfo {
|
|
|
86
86
|
case 3:
|
|
87
87
|
return 16;
|
|
88
88
|
default:
|
|
89
|
-
throw
|
|
89
|
+
throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_INVALID_FETCH_MESSAGE_DATA, `FetchBlockRawResp getTypeSkip error, type: ${v}`);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
parseBlockInfos(dataView) {
|
|
@@ -109,9 +109,14 @@ class WSTmqFetchBlockInfo {
|
|
|
109
109
|
dataBuffer = this.parseSchemaInfo(dataView, offset);
|
|
110
110
|
rows += this.parseTmqBlock(dataView, 1);
|
|
111
111
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
log_1.default.info("parseBlockInfos blockNum=" +
|
|
113
|
+
blockNum +
|
|
114
|
+
", withTableName=" +
|
|
115
|
+
this.withTableName +
|
|
116
|
+
", withSchema=" +
|
|
117
|
+
this.withSchema +
|
|
118
|
+
", rows=" +
|
|
119
|
+
rows);
|
|
115
120
|
return rows;
|
|
116
121
|
}
|
|
117
122
|
parseSchemaInfo(dataBuffer, offset) {
|
|
@@ -142,7 +147,7 @@ class WSTmqFetchBlockInfo {
|
|
|
142
147
|
this.taosResult.setMeta({
|
|
143
148
|
name: schema.name,
|
|
144
149
|
type: schema.colType,
|
|
145
|
-
length: Number(schema.bytes)
|
|
150
|
+
length: Number(schema.bytes),
|
|
146
151
|
});
|
|
147
152
|
this.schema.push(schema);
|
|
148
153
|
}
|
|
@@ -177,7 +182,11 @@ class WSTmqFetchBlockInfo {
|
|
|
177
182
|
multiplier *= 128;
|
|
178
183
|
count++;
|
|
179
184
|
}
|
|
180
|
-
return [
|
|
185
|
+
return [
|
|
186
|
+
value,
|
|
187
|
+
new DataView(dataView.buffer, dataView.byteOffset + count + 1 + offset),
|
|
188
|
+
count + 1,
|
|
189
|
+
];
|
|
181
190
|
}
|
|
182
191
|
parseTmqBlock(dataView, startOffset) {
|
|
183
192
|
// let dataView = new DataView(dataBuffer)
|
|
@@ -201,9 +210,9 @@ class WSTmqFetchBlockInfo {
|
|
|
201
210
|
bufferOffset += this.schema.length * 4;
|
|
202
211
|
for (let i = 0; i < this.schema.length; i++) {
|
|
203
212
|
let data = [];
|
|
204
|
-
//get type code
|
|
213
|
+
//get type code
|
|
205
214
|
let isVarType = (0, taosResult_1._isVarType)(this.schema[i].colType);
|
|
206
|
-
//fixed length type
|
|
215
|
+
//fixed length type
|
|
207
216
|
if (isVarType == constant_1.ColumnsBlockType.SOLID) {
|
|
208
217
|
// let bitMapArr = dataBuffer.slice(bufferOffset, bufferOffset + bitMapOffset);
|
|
209
218
|
let bitMapArr = new Uint8Array(dataView.buffer, dataView.byteOffset + bufferOffset, bitMapOffset);
|
|
@@ -212,26 +221,27 @@ class WSTmqFetchBlockInfo {
|
|
|
212
221
|
data = (0, taosResult_1.readSolidDataToArray)(dataView, bufferOffset, rows, this.schema[i].colType, bitMapArr, startOffset, i);
|
|
213
222
|
}
|
|
214
223
|
else {
|
|
215
|
-
//Variable length type
|
|
224
|
+
//Variable length type
|
|
216
225
|
let start = bufferOffset;
|
|
217
226
|
let offsets = [];
|
|
218
|
-
for (let i = 0; i < rows; i++, start += constant_1.TDengineTypeLength[
|
|
227
|
+
for (let i = 0; i < rows; i++, start += constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.INT]) {
|
|
219
228
|
//get data length, -1 is null
|
|
220
229
|
offsets.push(dataView.getInt32(start, true));
|
|
221
230
|
}
|
|
222
231
|
for (let i = 0; i < rows; i++) {
|
|
223
|
-
let value =
|
|
232
|
+
let value = "";
|
|
224
233
|
if (-1 == offsets[i]) {
|
|
225
234
|
value = null;
|
|
226
235
|
}
|
|
227
236
|
else {
|
|
228
237
|
let header = start + offsets[i];
|
|
229
|
-
let dataLength = dataView.getInt16(header, true) &
|
|
238
|
+
let dataLength = dataView.getInt16(header, true) & 0xffff;
|
|
230
239
|
if (isVarType == constant_1.ColumnsBlockType.VARCHAR) {
|
|
231
240
|
//decode var char
|
|
232
241
|
value = (0, taosResult_1.readVarchar)(dataView.buffer, dataView.byteOffset + header + 2, dataLength, this.textDecoder);
|
|
233
242
|
}
|
|
234
|
-
else if (isVarType == constant_1.ColumnsBlockType.GEOMETRY ||
|
|
243
|
+
else if (isVarType == constant_1.ColumnsBlockType.GEOMETRY ||
|
|
244
|
+
isVarType == constant_1.ColumnsBlockType.VARBINARY) {
|
|
235
245
|
//decode binary
|
|
236
246
|
value = (0, taosResult_1.readBinary)(dataView.buffer, dataView.byteOffset + header + 2, dataLength);
|
|
237
247
|
}
|
|
@@ -294,11 +304,13 @@ class PartitionsResp {
|
|
|
294
304
|
this.req_id = resp.msg.req_id;
|
|
295
305
|
this.action = resp.msg.action;
|
|
296
306
|
this.totalTime = resp.totalTime;
|
|
297
|
-
this.positions = resp.msg.position
|
|
307
|
+
this.positions = resp.msg.position
|
|
308
|
+
? resp.msg.position.map((pos) => BigInt(pos))
|
|
309
|
+
: [];
|
|
298
310
|
}
|
|
299
311
|
setTopicPartitions(topicPartitions) {
|
|
300
312
|
if (topicPartitions.length != this.positions.length) {
|
|
301
|
-
throw new wsError_1.WebSocketInterfaceError(wsError_1.ErrorCode.ERR_PARTITIONS_TOPIC_VGROUP_LENGTH_NOT_EQUAL,
|
|
313
|
+
throw new wsError_1.WebSocketInterfaceError(wsError_1.ErrorCode.ERR_PARTITIONS_TOPIC_VGROUP_LENGTH_NOT_EQUAL, "TopicPartitions and positions are not equal in length");
|
|
302
314
|
}
|
|
303
315
|
for (let i in this.positions) {
|
|
304
316
|
topicPartitions[i].offset = this.positions[i];
|
|
@@ -310,7 +322,9 @@ exports.PartitionsResp = PartitionsResp;
|
|
|
310
322
|
class CommittedResp extends PartitionsResp {
|
|
311
323
|
constructor(resp) {
|
|
312
324
|
super(resp);
|
|
313
|
-
this.positions = resp.msg.committed
|
|
325
|
+
this.positions = resp.msg.committed
|
|
326
|
+
? resp.msg.committed.map((pos) => BigInt(pos))
|
|
327
|
+
: [];
|
|
314
328
|
}
|
|
315
329
|
}
|
|
316
330
|
exports.CommittedResp = CommittedResp;
|
|
@@ -320,7 +334,7 @@ class TopicPartition {
|
|
|
320
334
|
this.offset = BigInt(msg.offset);
|
|
321
335
|
this.begin = BigInt(msg.begin);
|
|
322
336
|
this.end = BigInt(msg.end);
|
|
323
|
-
this.topic =
|
|
337
|
+
this.topic = "";
|
|
324
338
|
}
|
|
325
339
|
}
|
|
326
340
|
exports.TopicPartition = TopicPartition;
|
package/lib/src/tmq/wsTmq.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TaosResult } from
|
|
2
|
-
import { TopicPartition } from
|
|
1
|
+
import { TaosResult } from "../common/taosResult";
|
|
2
|
+
import { TopicPartition } from "./tmqResponse";
|
|
3
3
|
export declare class WsConsumer {
|
|
4
4
|
private _wsClient;
|
|
5
5
|
private _wsConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsTmq.d.ts","sourceRoot":"","sources":["../../../src/tmq/wsTmq.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"wsTmq.d.ts","sourceRoot":"","sources":["../../../src/tmq/wsTmq.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAOlD,OAAO,EAMH,cAAc,EAIjB,MAAM,eAAe,CAAC;AAKvB,qBAAa,UAAU;IACnB,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,OAAO,CAAC,CAAW;IAC3B,OAAO,CAAC,WAAW,CAAC,CAAS;IAC7B,OAAO,CAAC,cAAc,CAAC,CAAS;IAChC,OAAO;YAgBO,IAAI;WA4BL,WAAW,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IAWnE,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA2B/D,WAAW,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU1C,IAAI,CACN,SAAS,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAgB7B,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAYpD,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;YAK9C,QAAQ;IAYhB,SAAS,CACX,UAAU,EAAE,KAAK,CAAC,cAAc,CAAC,EACjC,KAAK,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAgC3B,aAAa,CACf,UAAU,EAAE,KAAK,CAAC,cAAc,CAAC,GAClC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAe3B,YAAY,CACd,SAAS,EAAE,cAAc,EACzB,KAAK,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;IAoBV,SAAS,CACX,UAAU,EAAE,KAAK,CAAC,cAAc,CAAC,EACjC,KAAK,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IA4B3B,IAAI,CAAC,SAAS,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB9D,eAAe,CAAC,UAAU,EAAE,KAAK,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAUjE,SAAS,CAAC,UAAU,EAAE,KAAK,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAW3D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAId,cAAc;YAgCd,QAAQ;YAsCR,iBAAiB;IAgBzB,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;YAoBrD,gBAAgB;CAmCjC"}
|
package/lib/src/tmq/wsTmq.js
CHANGED
|
@@ -18,7 +18,7 @@ class WsConsumer {
|
|
|
18
18
|
this._wsConfig = new config_1.TmqConfig(wsConfig);
|
|
19
19
|
log_1.default.debug(this._wsConfig);
|
|
20
20
|
if (wsConfig.size == 0 || !this._wsConfig.url) {
|
|
21
|
-
throw new wsError_1.WebSocketInterfaceError(wsError_1.ErrorCode.ERR_INVALID_URL,
|
|
21
|
+
throw new wsError_1.WebSocketInterfaceError(wsError_1.ErrorCode.ERR_INVALID_URL, "invalid url, password or username needed.");
|
|
22
22
|
}
|
|
23
23
|
this._wsClient = new wsClient_1.WsClient(this._wsConfig.url, this._wsConfig.timeout);
|
|
24
24
|
this._lastMessageID = BigInt(0);
|
|
@@ -33,12 +33,12 @@ class WsConsumer {
|
|
|
33
33
|
await this._wsClient.ready();
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
|
-
throw
|
|
36
|
+
throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `connection creation failed, url: ${this._wsConfig.url}`);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
catch (e) {
|
|
40
40
|
await this._wsClient.close();
|
|
41
|
-
throw
|
|
41
|
+
throw e;
|
|
42
42
|
}
|
|
43
43
|
finally {
|
|
44
44
|
if (wsSql) {
|
|
@@ -49,14 +49,14 @@ class WsConsumer {
|
|
|
49
49
|
}
|
|
50
50
|
static async newConsumer(wsConfig) {
|
|
51
51
|
if (wsConfig.size == 0 || !wsConfig.get(constant_1.TMQConstants.WS_URL)) {
|
|
52
|
-
throw new wsError_1.WebSocketInterfaceError(wsError_1.ErrorCode.ERR_INVALID_URL,
|
|
52
|
+
throw new wsError_1.WebSocketInterfaceError(wsError_1.ErrorCode.ERR_INVALID_URL, "invalid url, password or username needed.");
|
|
53
53
|
}
|
|
54
54
|
let wsConsumer = new WsConsumer(wsConfig);
|
|
55
55
|
return await wsConsumer.init();
|
|
56
56
|
}
|
|
57
57
|
async subscribe(topics, reqId) {
|
|
58
58
|
if (!topics || topics.length == 0) {
|
|
59
|
-
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS,
|
|
59
|
+
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "WsTmq Subscribe params is error!");
|
|
60
60
|
}
|
|
61
61
|
let queryMsg = {
|
|
62
62
|
action: constant_1.TMQMessageType.Subscribe,
|
|
@@ -70,7 +70,7 @@ class WsConsumer {
|
|
|
70
70
|
offset_rest: this._wsConfig.offset_rest,
|
|
71
71
|
auto_commit: this._wsConfig.auto_commit,
|
|
72
72
|
auto_commit_interval_ms: this._wsConfig.auto_commit_interval_ms,
|
|
73
|
-
config: this._wsConfig.otherConfigs
|
|
73
|
+
config: this._wsConfig.otherConfigs,
|
|
74
74
|
},
|
|
75
75
|
};
|
|
76
76
|
this._topics = topics;
|
|
@@ -120,20 +120,20 @@ class WsConsumer {
|
|
|
120
120
|
action: constant_1.TMQMessageType.Commit,
|
|
121
121
|
args: {
|
|
122
122
|
req_id: reqid_1.ReqId.getReqID(reqId),
|
|
123
|
-
message_id: 0
|
|
123
|
+
message_id: 0,
|
|
124
124
|
},
|
|
125
125
|
};
|
|
126
126
|
await this._wsClient.exec(JSON.stringify(queryMsg));
|
|
127
127
|
}
|
|
128
128
|
async committed(partitions, reqId) {
|
|
129
129
|
if (!partitions || partitions.length == 0) {
|
|
130
|
-
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS,
|
|
130
|
+
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "WsTmq Positions params is error!");
|
|
131
131
|
}
|
|
132
132
|
let offsets = new Array(partitions.length);
|
|
133
133
|
for (let i = 0; i < partitions.length; i++) {
|
|
134
134
|
offsets[i] = {
|
|
135
135
|
topic: partitions[i].topic,
|
|
136
|
-
vgroup_id: partitions[i].vgroup_id
|
|
136
|
+
vgroup_id: partitions[i].vgroup_id,
|
|
137
137
|
};
|
|
138
138
|
offsets[i].vgroup_id = partitions[i].vgroup_id;
|
|
139
139
|
}
|
|
@@ -141,7 +141,7 @@ class WsConsumer {
|
|
|
141
141
|
action: constant_1.TMQMessageType.Committed,
|
|
142
142
|
args: {
|
|
143
143
|
req_id: reqid_1.ReqId.getReqID(reqId),
|
|
144
|
-
topic_vgroup_ids: offsets
|
|
144
|
+
topic_vgroup_ids: offsets,
|
|
145
145
|
},
|
|
146
146
|
};
|
|
147
147
|
let resp = await this._wsClient.exec(json_bigint_1.default.stringify(queryMsg), false);
|
|
@@ -149,10 +149,10 @@ class WsConsumer {
|
|
|
149
149
|
}
|
|
150
150
|
async commitOffsets(partitions) {
|
|
151
151
|
if (!partitions || partitions.length == 0) {
|
|
152
|
-
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS,
|
|
152
|
+
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "WsTmq CommitOffsets params is error!");
|
|
153
153
|
}
|
|
154
154
|
const allp = [];
|
|
155
|
-
partitions.forEach(e => {
|
|
155
|
+
partitions.forEach((e) => {
|
|
156
156
|
allp.push(this.commitOffset(e));
|
|
157
157
|
});
|
|
158
158
|
await Promise.all(allp);
|
|
@@ -160,7 +160,7 @@ class WsConsumer {
|
|
|
160
160
|
}
|
|
161
161
|
async commitOffset(partition, reqId) {
|
|
162
162
|
if (!partition) {
|
|
163
|
-
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS,
|
|
163
|
+
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "WsTmq CommitOffsets params is error!");
|
|
164
164
|
}
|
|
165
165
|
let queryMsg = {
|
|
166
166
|
action: constant_1.TMQMessageType.CommitOffset,
|
|
@@ -175,13 +175,13 @@ class WsConsumer {
|
|
|
175
175
|
}
|
|
176
176
|
async positions(partitions, reqId) {
|
|
177
177
|
if (!partitions || partitions.length == 0) {
|
|
178
|
-
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS,
|
|
178
|
+
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "WsTmq Positions params is error!");
|
|
179
179
|
}
|
|
180
180
|
let offsets = new Array(partitions.length);
|
|
181
181
|
for (let i = 0; i < partitions.length; i++) {
|
|
182
182
|
offsets[i] = {
|
|
183
183
|
topic: partitions[i].topic,
|
|
184
|
-
vgroup_id: partitions[i].vgroup_id
|
|
184
|
+
vgroup_id: partitions[i].vgroup_id,
|
|
185
185
|
};
|
|
186
186
|
offsets[i].vgroup_id = partitions[i].vgroup_id;
|
|
187
187
|
}
|
|
@@ -189,7 +189,7 @@ class WsConsumer {
|
|
|
189
189
|
action: constant_1.TMQMessageType.Position,
|
|
190
190
|
args: {
|
|
191
191
|
req_id: reqid_1.ReqId.getReqID(reqId),
|
|
192
|
-
topic_vgroup_ids: offsets
|
|
192
|
+
topic_vgroup_ids: offsets,
|
|
193
193
|
},
|
|
194
194
|
};
|
|
195
195
|
let resp = await this._wsClient.exec(JSON.stringify(queryMsg), false);
|
|
@@ -197,7 +197,7 @@ class WsConsumer {
|
|
|
197
197
|
}
|
|
198
198
|
async seek(partition, reqId) {
|
|
199
199
|
if (!partition) {
|
|
200
|
-
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS,
|
|
200
|
+
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "WsTmq Seek params is error!");
|
|
201
201
|
}
|
|
202
202
|
let queryMsg = {
|
|
203
203
|
action: constant_1.TMQMessageType.Seek,
|
|
@@ -212,13 +212,13 @@ class WsConsumer {
|
|
|
212
212
|
}
|
|
213
213
|
async seekToBeginning(partitions) {
|
|
214
214
|
if (!partitions || partitions.length == 0) {
|
|
215
|
-
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS,
|
|
215
|
+
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "WsTmq SeekToBeginning params is error!");
|
|
216
216
|
}
|
|
217
217
|
return await this.seekToBeginOrEnd(partitions);
|
|
218
218
|
}
|
|
219
219
|
async seekToEnd(partitions) {
|
|
220
220
|
if (!partitions || partitions.length == 0) {
|
|
221
|
-
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS,
|
|
221
|
+
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "WsTmq SeekToEnd params is error!");
|
|
222
222
|
}
|
|
223
223
|
return await this.seekToBeginOrEnd(partitions, false);
|
|
224
224
|
}
|
|
@@ -227,19 +227,20 @@ class WsConsumer {
|
|
|
227
227
|
}
|
|
228
228
|
async fetchBlockData(pollResp, taosResult) {
|
|
229
229
|
let fetchMsg = {
|
|
230
|
-
action:
|
|
230
|
+
action: "fetch_raw_data",
|
|
231
231
|
args: {
|
|
232
232
|
req_id: reqid_1.ReqId.getReqID(),
|
|
233
233
|
message_id: pollResp.message_id,
|
|
234
234
|
},
|
|
235
235
|
};
|
|
236
236
|
let jsonStr = json_bigint_1.default.stringify(fetchMsg);
|
|
237
|
-
log_1.default.debug(
|
|
237
|
+
log_1.default.debug("[wsQueryInterface.fetch.fetchMsg]===>" + jsonStr);
|
|
238
238
|
let result = await this._wsClient.sendMsg(jsonStr);
|
|
239
239
|
let wsResponse = new wsResponse_1.WSFetchBlockResponse(result.msg);
|
|
240
240
|
if (wsResponse && wsResponse.data && wsResponse.blockLen > 0) {
|
|
241
241
|
let wsTmqResponse = new tmqResponse_1.WSTmqFetchBlockInfo(wsResponse.data, taosResult);
|
|
242
|
-
log_1.default.debug(
|
|
242
|
+
log_1.default.debug("[WSTmqFetchBlockInfo.fetchBlockData]===>" +
|
|
243
|
+
wsTmqResponse.taosResult);
|
|
243
244
|
if (wsTmqResponse.rows > 0) {
|
|
244
245
|
return true;
|
|
245
246
|
}
|
|
@@ -260,7 +261,8 @@ class WsConsumer {
|
|
|
260
261
|
let taosResult = new tmqResponse_1.TaosTmqResult(pollResp);
|
|
261
262
|
var taosResults = new Map();
|
|
262
263
|
taosResults.set(pollResp.topic, taosResult);
|
|
263
|
-
if (!pollResp.have_message ||
|
|
264
|
+
if (!pollResp.have_message ||
|
|
265
|
+
pollResp.message_type != constant_1.TMQMessageType.ResDataType) {
|
|
264
266
|
return taosResults;
|
|
265
267
|
}
|
|
266
268
|
this._lastMessageID = pollResp.message_id;
|
|
@@ -275,8 +277,8 @@ class WsConsumer {
|
|
|
275
277
|
action: constant_1.TMQMessageType.GetTopicAssignment,
|
|
276
278
|
args: {
|
|
277
279
|
req_id: reqid_1.ReqId.getReqID(),
|
|
278
|
-
topic: topic
|
|
279
|
-
}
|
|
280
|
+
topic: topic,
|
|
281
|
+
},
|
|
280
282
|
};
|
|
281
283
|
let resp = await this._wsClient.exec(JSON.stringify(queryMsg), false);
|
|
282
284
|
let assignmentInfo = new tmqResponse_1.AssignmentResp(resp, queryMsg.args.topic);
|
|
@@ -293,7 +295,7 @@ class WsConsumer {
|
|
|
293
295
|
allp.push(this.sendAssignmentReq(topics[i]));
|
|
294
296
|
}
|
|
295
297
|
let result = await Promise.all(allp);
|
|
296
|
-
result.forEach(e => {
|
|
298
|
+
result.forEach((e) => {
|
|
297
299
|
topicPartitions.push(...e);
|
|
298
300
|
});
|
|
299
301
|
}
|
|
@@ -301,18 +303,18 @@ class WsConsumer {
|
|
|
301
303
|
}
|
|
302
304
|
async seekToBeginOrEnd(partitions, bBegin = true) {
|
|
303
305
|
let topics = [];
|
|
304
|
-
partitions.forEach(e => {
|
|
306
|
+
partitions.forEach((e) => {
|
|
305
307
|
topics.push(e.topic);
|
|
306
308
|
});
|
|
307
309
|
let topicPartitions = await this.assignment(topics);
|
|
308
310
|
let itemMap = topicPartitions.reduce((map, obj) => {
|
|
309
|
-
map.set(obj.topic +
|
|
311
|
+
map.set(obj.topic + "_" + obj.vgroup_id, obj);
|
|
310
312
|
return map;
|
|
311
313
|
}, new Map());
|
|
312
314
|
const allp = [];
|
|
313
315
|
for (let i in partitions) {
|
|
314
|
-
if (itemMap.has(partitions[i].topic +
|
|
315
|
-
let topicPartition = itemMap.get(partitions[i].topic +
|
|
316
|
+
if (itemMap.has(partitions[i].topic + "_" + partitions[i].vgroup_id)) {
|
|
317
|
+
let topicPartition = itemMap.get(partitions[i].topic + "_" + partitions[i].vgroup_id);
|
|
316
318
|
if (topicPartition) {
|
|
317
319
|
if (bBegin) {
|
|
318
320
|
topicPartition.offset = topicPartition.begin;
|
|
@@ -11,8 +11,8 @@ beforeAll(async () => {
|
|
|
11
11
|
let wsSql = null;
|
|
12
12
|
try {
|
|
13
13
|
const conf = new config_1.WSConfig(url);
|
|
14
|
-
conf.setUser(
|
|
15
|
-
conf.setPwd(
|
|
14
|
+
conf.setUser("root");
|
|
15
|
+
conf.setPwd("taosdata");
|
|
16
16
|
wsSql = await wsSql_1.WsSql.open(conf);
|
|
17
17
|
let sql = `INSERT INTO dmeters.d1001 USING dmeters.meters (groupid, location) TAGS(2, 'SanFrancisco')
|
|
18
18
|
VALUES (NOW + 1a, 10.30000, 219, 0.31000) (NOW + 2a, 12.60000, 218, 0.33000) (NOW + 3a, 12.30000, 221, 0.31000)
|
|
@@ -31,21 +31,21 @@ beforeAll(async () => {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
|
-
describe(
|
|
34
|
+
describe("TDWebSocket.Tmq()", () => {
|
|
35
35
|
jest.setTimeout(20 * 1000);
|
|
36
|
-
test(
|
|
36
|
+
test("normal connect", async () => {
|
|
37
37
|
const url = `wss://${process.env.TDENGINE_CLOUD_URL}?token=${process.env.TDENGINE_CLOUD_TOKEN}`;
|
|
38
|
-
const topic =
|
|
38
|
+
const topic = "topic_meters";
|
|
39
39
|
const topics = [topic];
|
|
40
|
-
const groupId =
|
|
41
|
-
const clientId =
|
|
40
|
+
const groupId = "group1";
|
|
41
|
+
const clientId = "client1";
|
|
42
42
|
let configMap = new Map([
|
|
43
43
|
[constant_1.TMQConstants.GROUP_ID, groupId],
|
|
44
44
|
[constant_1.TMQConstants.CLIENT_ID, clientId],
|
|
45
|
-
[constant_1.TMQConstants.AUTO_OFFSET_RESET,
|
|
45
|
+
[constant_1.TMQConstants.AUTO_OFFSET_RESET, "earliest"],
|
|
46
46
|
[constant_1.TMQConstants.WS_URL, url],
|
|
47
|
-
[constant_1.TMQConstants.ENABLE_AUTO_COMMIT,
|
|
48
|
-
[constant_1.TMQConstants.AUTO_COMMIT_INTERVAL_MS,
|
|
47
|
+
[constant_1.TMQConstants.ENABLE_AUTO_COMMIT, "true"],
|
|
48
|
+
[constant_1.TMQConstants.AUTO_COMMIT_INTERVAL_MS, "1000"],
|
|
49
49
|
]);
|
|
50
50
|
(0, log_1.setLevel)("debug");
|
|
51
51
|
// create consumer
|
|
@@ -68,7 +68,7 @@ describe('TDWebSocket.Tmq()', () => {
|
|
|
68
68
|
// seek
|
|
69
69
|
let assignment = await consumer.assignment();
|
|
70
70
|
await consumer.seekToBeginning(assignment);
|
|
71
|
-
console.log(
|
|
71
|
+
console.log("Assignment seek to beginning successfully");
|
|
72
72
|
// clean
|
|
73
73
|
await consumer.unsubscribe();
|
|
74
74
|
await consumer.close();
|