@tdengine/websocket 3.2.3 → 3.3.0
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/package.json +1 -1
- package/lib/src/client/wsClient.d.ts +23 -7
- package/lib/src/client/wsClient.d.ts.map +1 -1
- package/lib/src/client/wsClient.js +154 -139
- package/lib/src/client/wsConnector.d.ts +55 -9
- package/lib/src/client/wsConnector.d.ts.map +1 -1
- package/lib/src/client/wsConnector.js +519 -100
- package/lib/src/client/wsConnectorPool.d.ts +5 -1
- package/lib/src/client/wsConnectorPool.d.ts.map +1 -1
- package/lib/src/client/wsConnectorPool.js +61 -43
- package/lib/src/client/wsEventCallback.d.ts +3 -0
- package/lib/src/client/wsEventCallback.d.ts.map +1 -1
- package/lib/src/client/wsEventCallback.js +67 -8
- package/lib/src/common/addressConnectionTracker.d.ts +11 -0
- package/lib/src/common/addressConnectionTracker.d.ts.map +1 -0
- package/lib/src/common/addressConnectionTracker.js +53 -0
- package/lib/src/common/dsn.d.ts +14 -2
- package/lib/src/common/dsn.d.ts.map +1 -1
- package/lib/src/common/dsn.js +91 -22
- package/lib/src/common/taosResult.d.ts.map +1 -1
- package/lib/src/common/taosResult.js +0 -5
- package/lib/src/common/urlParser.d.ts +32 -0
- package/lib/src/common/urlParser.d.ts.map +1 -0
- package/lib/src/common/urlParser.js +201 -0
- package/lib/src/common/utils.d.ts +2 -1
- package/lib/src/common/utils.d.ts.map +1 -1
- package/lib/src/common/utils.js +35 -34
- package/lib/src/sql/wsSql.js +2 -2
- package/lib/src/stmt/FieldBindParams.d.ts.map +1 -1
- package/lib/src/stmt/wsColumnInfo.d.ts.map +1 -1
- package/lib/src/stmt/wsParams1.d.ts.map +1 -1
- package/lib/src/stmt/wsParams1.js +26 -26
- package/lib/src/stmt/wsParams2.d.ts.map +1 -1
- package/lib/src/stmt/wsParams2.js +0 -3
- package/lib/src/stmt/wsParamsBase.d.ts.map +1 -1
- package/lib/src/stmt/wsProto.d.ts.map +1 -1
- package/lib/src/stmt/wsProto.js +16 -16
- package/lib/src/stmt/wsStmt1.d.ts.map +1 -1
- package/lib/src/stmt/wsStmt2.d.ts +12 -4
- package/lib/src/stmt/wsStmt2.d.ts.map +1 -1
- package/lib/src/stmt/wsStmt2.js +182 -64
- package/lib/src/stmt/wsTableInfo.d.ts.map +1 -1
- package/lib/src/tmq/config.d.ts +3 -2
- package/lib/src/tmq/config.d.ts.map +1 -1
- package/lib/src/tmq/config.js +15 -15
- package/lib/src/tmq/wsTmq.d.ts +4 -1
- package/lib/src/tmq/wsTmq.d.ts.map +1 -1
- package/lib/src/tmq/wsTmq.js +50 -27
- package/lib/test/bulkPulling/a.test.d.ts +2 -0
- package/lib/test/bulkPulling/a.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/a.test.js +166 -0
- package/lib/test/bulkPulling/dsn.test.js +19 -0
- package/lib/test/bulkPulling/retryConfig.test.js +11 -11
- package/lib/test/bulkPulling/sql.failover.test.d.ts +2 -0
- package/lib/test/bulkPulling/sql.failover.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/sql.failover.test.js +338 -0
- package/lib/test/bulkPulling/stmt2.failover.test.d.ts +2 -0
- package/lib/test/bulkPulling/stmt2.failover.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/stmt2.failover.test.js +313 -0
- package/lib/test/bulkPulling/stmt2.init.failover.test.d.ts +2 -0
- package/lib/test/bulkPulling/stmt2.init.failover.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/stmt2.init.failover.test.js +50 -0
- package/lib/test/bulkPulling/tmq.failover.test.d.ts +2 -0
- package/lib/test/bulkPulling/tmq.failover.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/tmq.failover.test.js +404 -0
- package/lib/test/bulkPulling/urlParser.test.d.ts +2 -0
- package/lib/test/bulkPulling/urlParser.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/urlParser.test.js +452 -0
- package/lib/test/bulkPulling/wsClient.reconnect.integration.test.js +2 -2
- package/lib/test/bulkPulling/wsClient.recovery.test.d.ts +2 -0
- package/lib/test/bulkPulling/wsClient.recovery.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/wsClient.recovery.test.js +104 -0
- package/lib/test/bulkPulling/wsConfig.dsn.test.js +2 -0
- package/lib/test/bulkPulling/wsConnector.failover.test.js +396 -27
- package/lib/test/bulkPulling/wsConnectorPool.key.test.js +12 -10
- package/lib/test/bulkPulling/wsConnectorPool.keyAuth.test.d.ts +2 -0
- package/lib/test/bulkPulling/wsConnectorPool.keyAuth.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/wsConnectorPool.keyAuth.test.js +28 -0
- package/lib/test/bulkPulling/wsProxy.failover.integration.test.d.ts +2 -0
- package/lib/test/bulkPulling/wsProxy.failover.integration.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/wsProxy.failover.integration.test.js +120 -0
- package/lib/test/bulkPulling/wsProxy.failover.test.d.ts +2 -0
- package/lib/test/bulkPulling/wsProxy.failover.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/wsProxy.failover.test.js +465 -0
- package/lib/test/client/wsClient.recovery.test.d.ts +2 -0
- package/lib/test/client/wsClient.recovery.test.d.ts.map +1 -0
- package/lib/test/client/wsClient.recovery.test.js +122 -0
- package/lib/test/client/wsConnectPool.test.d.ts +2 -0
- package/lib/test/client/wsConnectPool.test.d.ts.map +1 -0
- package/lib/test/client/wsConnectPool.test.js +147 -0
- package/lib/test/client/wsConnector.failover.test.d.ts +2 -0
- package/lib/test/client/wsConnector.failover.test.d.ts.map +1 -0
- package/lib/test/client/wsConnector.failover.test.js +681 -0
- package/lib/test/client/wsConnector.leastConnections.test.d.ts +2 -0
- package/lib/test/client/wsConnector.leastConnections.test.d.ts.map +1 -0
- package/lib/test/client/wsConnector.leastConnections.test.js +71 -0
- package/lib/test/client/wsConnectorPool.key.test.d.ts +2 -0
- package/lib/test/client/wsConnectorPool.key.test.d.ts.map +1 -0
- package/lib/test/client/wsConnectorPool.key.test.js +127 -0
- package/lib/test/client/wsEventCallback.test.d.ts +2 -0
- package/lib/test/client/wsEventCallback.test.d.ts.map +1 -0
- package/lib/test/client/wsEventCallback.test.js +98 -0
- package/lib/test/common/addressConnectionTracker.test.d.ts +2 -0
- package/lib/test/common/addressConnectionTracker.test.d.ts.map +1 -0
- package/lib/test/common/addressConnectionTracker.test.js +74 -0
- package/lib/test/common/dsn.test.d.ts +2 -0
- package/lib/test/common/dsn.test.d.ts.map +1 -0
- package/lib/test/common/dsn.test.js +406 -0
- package/lib/test/common/log.test.d.ts +2 -0
- package/lib/test/common/log.test.d.ts.map +1 -0
- package/lib/test/common/log.test.js +54 -0
- package/lib/test/common/utils.test.d.ts +2 -0
- package/lib/test/common/utils.test.d.ts.map +1 -0
- package/lib/test/common/utils.test.js +13 -0
- package/lib/test/common/wsConfig.dsn.test.d.ts +2 -0
- package/lib/test/common/wsConfig.dsn.test.d.ts.map +1 -0
- package/lib/test/common/wsConfig.dsn.test.js +39 -0
- package/lib/test/helpers/utils.d.ts +27 -0
- package/lib/test/helpers/utils.d.ts.map +1 -0
- package/lib/test/helpers/utils.js +341 -0
- package/lib/test/helpers/wsFailoverProxy.d.ts +109 -0
- package/lib/test/helpers/wsFailoverProxy.d.ts.map +1 -0
- package/lib/test/helpers/wsFailoverProxy.js +420 -0
- package/lib/test/helpers/wsProxy.d.ts +110 -0
- package/lib/test/helpers/wsProxy.d.ts.map +1 -0
- package/lib/test/helpers/wsProxy.js +429 -0
- package/lib/test/sql/core/decimal.test.d.ts +2 -0
- package/lib/test/sql/core/decimal.test.d.ts.map +1 -0
- package/lib/test/sql/core/decimal.test.js +153 -0
- package/lib/test/sql/core/queryTables.test.d.ts +2 -0
- package/lib/test/sql/core/queryTables.test.d.ts.map +1 -0
- package/lib/test/sql/core/queryTables.test.js +506 -0
- package/lib/test/sql/core/schemaless.test.d.ts +2 -0
- package/lib/test/sql/core/schemaless.test.d.ts.map +1 -0
- package/lib/test/sql/core/schemaless.test.js +102 -0
- package/lib/test/sql/core/sql.test.d.ts +2 -0
- package/lib/test/sql/core/sql.test.d.ts.map +1 -0
- package/lib/test/sql/core/sql.test.js +324 -0
- package/lib/test/sql/decimal.test.d.ts +2 -0
- package/lib/test/sql/decimal.test.d.ts.map +1 -0
- package/lib/test/sql/decimal.test.js +153 -0
- package/lib/test/sql/failover/sql.failover.test.d.ts +2 -0
- package/lib/test/sql/failover/sql.failover.test.d.ts.map +1 -0
- package/lib/test/sql/failover/sql.failover.test.js +341 -0
- package/lib/test/sql/queryTables.test.d.ts +2 -0
- package/lib/test/sql/queryTables.test.d.ts.map +1 -0
- package/lib/test/sql/queryTables.test.js +506 -0
- package/lib/test/sql/schemaless.test.d.ts +2 -0
- package/lib/test/sql/schemaless.test.d.ts.map +1 -0
- package/lib/test/sql/schemaless.test.js +102 -0
- package/lib/test/sql/sql.failover.test.d.ts +2 -0
- package/lib/test/sql/sql.failover.test.d.ts.map +1 -0
- package/lib/test/sql/sql.failover.test.js +341 -0
- package/lib/test/sql/sql.test.d.ts +2 -0
- package/lib/test/sql/sql.test.d.ts.map +1 -0
- package/lib/test/sql/sql.test.js +324 -0
- package/lib/test/stmt/failover/stmt2.failover.mock.test.d.ts +2 -0
- package/lib/test/stmt/failover/stmt2.failover.mock.test.d.ts.map +1 -0
- package/lib/test/stmt/failover/stmt2.failover.mock.test.js +341 -0
- package/lib/test/stmt/failover/stmt2.failover.test.d.ts +2 -0
- package/lib/test/stmt/failover/stmt2.failover.test.d.ts.map +1 -0
- package/lib/test/stmt/failover/stmt2.failover.test.js +384 -0
- package/lib/test/stmt/stmt1.func.test.d.ts +2 -0
- package/lib/test/stmt/stmt1.func.test.d.ts.map +1 -0
- package/lib/test/stmt/stmt1.func.test.js +418 -0
- package/lib/test/stmt/stmt1.type.test.d.ts +2 -0
- package/lib/test/stmt/stmt1.type.test.d.ts.map +1 -0
- package/lib/test/stmt/stmt1.type.test.js +399 -0
- package/lib/test/stmt/stmt2.failover.mock.test.d.ts +2 -0
- package/lib/test/stmt/stmt2.failover.mock.test.d.ts.map +1 -0
- package/lib/test/stmt/stmt2.failover.mock.test.js +341 -0
- package/lib/test/stmt/stmt2.failover.test.d.ts +2 -0
- package/lib/test/stmt/stmt2.failover.test.d.ts.map +1 -0
- package/lib/test/stmt/stmt2.failover.test.js +384 -0
- package/lib/test/stmt/stmt2.func.test.d.ts +2 -0
- package/lib/test/stmt/stmt2.func.test.d.ts.map +1 -0
- package/lib/test/stmt/stmt2.func.test.js +537 -0
- package/lib/test/stmt/stmt2.type.test.d.ts +2 -0
- package/lib/test/stmt/stmt2.type.test.d.ts.map +1 -0
- package/lib/test/stmt/stmt2.type.test.js +401 -0
- package/lib/test/stmt/v1/stmt1.func.test.d.ts +2 -0
- package/lib/test/stmt/v1/stmt1.func.test.d.ts.map +1 -0
- package/lib/test/stmt/v1/stmt1.func.test.js +418 -0
- package/lib/test/stmt/v1/stmt1.type.test.d.ts +2 -0
- package/lib/test/stmt/v1/stmt1.type.test.d.ts.map +1 -0
- package/lib/test/stmt/v1/stmt1.type.test.js +399 -0
- package/lib/test/stmt/v2/stmt2.func.test.d.ts +2 -0
- package/lib/test/stmt/v2/stmt2.func.test.d.ts.map +1 -0
- package/lib/test/stmt/v2/stmt2.func.test.js +537 -0
- package/lib/test/stmt/v2/stmt2.type.test.d.ts +2 -0
- package/lib/test/stmt/v2/stmt2.type.test.d.ts.map +1 -0
- package/lib/test/stmt/v2/stmt2.type.test.js +401 -0
- package/lib/test/tmq/cloud/cloud.tmq.test.d.ts +2 -0
- package/lib/test/tmq/cloud/cloud.tmq.test.d.ts.map +1 -0
- package/lib/test/tmq/cloud/cloud.tmq.test.js +84 -0
- package/lib/test/tmq/cloud/tmq.cloud.test.d.ts +2 -0
- package/lib/test/tmq/cloud/tmq.cloud.test.d.ts.map +1 -0
- package/lib/test/tmq/cloud/tmq.cloud.test.js +82 -0
- package/lib/test/tmq/core/tmq.config.test.d.ts +2 -0
- package/lib/test/tmq/core/tmq.config.test.d.ts.map +1 -0
- package/lib/test/tmq/core/tmq.config.test.js +83 -0
- package/lib/test/tmq/core/tmq.test.d.ts +2 -0
- package/lib/test/tmq/core/tmq.test.d.ts.map +1 -0
- package/lib/test/tmq/core/tmq.test.js +513 -0
- package/lib/test/tmq/failover/tmq.failover.test.d.ts +2 -0
- package/lib/test/tmq/failover/tmq.failover.test.d.ts.map +1 -0
- package/lib/test/tmq/failover/tmq.failover.test.js +404 -0
- package/lib/test/tmq/tmq.cloud.test.d.ts +2 -0
- package/lib/test/tmq/tmq.cloud.test.d.ts.map +1 -0
- package/lib/test/tmq/tmq.cloud.test.js +82 -0
- package/lib/test/tmq/tmq.config.test.d.ts +2 -0
- package/lib/test/tmq/tmq.config.test.d.ts.map +1 -0
- package/lib/test/tmq/tmq.config.test.js +94 -0
- package/lib/test/tmq/tmq.failover.test.d.ts +2 -0
- package/lib/test/tmq/tmq.failover.test.d.ts.map +1 -0
- package/lib/test/tmq/tmq.failover.test.js +404 -0
- package/lib/test/tmq/tmq.test.d.ts +2 -0
- package/lib/test/tmq/tmq.test.d.ts.map +1 -0
- package/lib/test/tmq/tmq.test.js +513 -0
- package/lib/test/unit/connectionManager.test.d.ts +2 -0
- package/lib/test/unit/connectionManager.test.d.ts.map +1 -0
- package/lib/test/unit/connectionManager.test.js +91 -0
- package/package.json +1 -1
- package/readme.md +2 -2
package/lib/src/stmt/wsProto.js
CHANGED
|
@@ -17,7 +17,7 @@ class WsStmtQueryResponse extends wsResponse_1.WSQueryResponse {
|
|
|
17
17
|
}
|
|
18
18
|
exports.WsStmtQueryResponse = WsStmtQueryResponse;
|
|
19
19
|
function binaryBlockEncode(bindParams, bindType, stmtId, reqId, row) {
|
|
20
|
-
//Computing the length of data
|
|
20
|
+
// Computing the length of data
|
|
21
21
|
let columns = bindParams.getParams().length;
|
|
22
22
|
let length = constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.BIGINT] * 4;
|
|
23
23
|
length += constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.INT] * 5;
|
|
@@ -28,40 +28,40 @@ function binaryBlockEncode(bindParams, bindType, stmtId, reqId, row) {
|
|
|
28
28
|
arrayView.setBigUint64(0, reqId, true);
|
|
29
29
|
arrayView.setBigUint64(8, stmtId, true);
|
|
30
30
|
arrayView.setBigUint64(16, BigInt(bindType), true);
|
|
31
|
-
//version int32
|
|
31
|
+
// version int32
|
|
32
32
|
arrayView.setUint32(24, 1, true);
|
|
33
|
-
//data length int32
|
|
33
|
+
// data length int32
|
|
34
34
|
arrayView.setUint32(28, arrayBuffer.byteLength, true);
|
|
35
|
-
//rows int32
|
|
35
|
+
// rows int32
|
|
36
36
|
arrayView.setUint32(32, row, true);
|
|
37
|
-
//columns int32
|
|
37
|
+
// columns int32
|
|
38
38
|
arrayView.setUint32(36, columns, true);
|
|
39
|
-
//flagSegment int32
|
|
39
|
+
// flagSegment int32
|
|
40
40
|
arrayView.setUint32(40, 0, true);
|
|
41
|
-
//groupID uint64
|
|
41
|
+
// groupID uint64
|
|
42
42
|
arrayView.setBigUint64(44, BigInt(0), true);
|
|
43
|
-
//head length
|
|
43
|
+
// head length
|
|
44
44
|
let offset = 52;
|
|
45
|
-
//type data range
|
|
45
|
+
// type data range
|
|
46
46
|
let typeView = new DataView(arrayBuffer, offset);
|
|
47
|
-
//length data range
|
|
47
|
+
// length data range
|
|
48
48
|
let lenView = new DataView(arrayBuffer, offset + columns * 5);
|
|
49
|
-
//data range offset
|
|
49
|
+
// data range offset
|
|
50
50
|
let dataOffset = offset + columns * 5 + columns * 4;
|
|
51
51
|
let headOffset = 0;
|
|
52
52
|
let columnsData = bindParams.getParams();
|
|
53
53
|
for (let i = 0; i < columnsData.length; i++) {
|
|
54
|
-
//set column data type
|
|
54
|
+
// set column data type
|
|
55
55
|
typeView.setUint8(headOffset, columnsData[i].type);
|
|
56
|
-
//set column type length
|
|
56
|
+
// set column type length
|
|
57
57
|
typeView.setUint32(headOffset + 1, columnsData[i].typeLen, true);
|
|
58
|
-
//set column data length
|
|
58
|
+
// set column data length
|
|
59
59
|
lenView.setUint32(i * 4, columnsData[i].length, true);
|
|
60
60
|
if (columnsData[i].data) {
|
|
61
|
-
//get encode column data
|
|
61
|
+
// get encode column data
|
|
62
62
|
const sourceView = new Uint8Array(columnsData[i].data);
|
|
63
63
|
const destView = new Uint8Array(arrayBuffer, dataOffset, columnsData[i].data.byteLength);
|
|
64
|
-
//splicing data
|
|
64
|
+
// splicing data
|
|
65
65
|
destView.set(sourceView);
|
|
66
66
|
dataOffset += columnsData[i].data.byteLength;
|
|
67
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsStmt1.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsStmt1.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAe9C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,qBAAa,OAAQ,YAAW,MAAM;IAClC,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,UAAU,CAAiC;
|
|
1
|
+
{"version":3,"file":"wsStmt1.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsStmt1.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAe9C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,qBAAa,OAAQ,YAAW,MAAM;IAClC,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,UAAU,CAAiC;IACnD,OAAO,CAAC,YAAY,CAA4B;IAEhD,OAAO;WAOM,OAAO,CAChB,QAAQ,EAAE,QAAQ,EAClB,SAAS,CAAC,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC;IAUZ,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,IAAI,eAAe;IAIzB,OAAO,CAAC,WAAW,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BnD,IAAI,CAAC,WAAW,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BhD,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;IAWrB,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAIlC,eAAe;IAIT,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAWrB,SAAS,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;YAI/B,OAAO;YAiCP,aAAa;YA2Bb,IAAI;CAyBrB"}
|
|
@@ -5,7 +5,6 @@ import { WSRows } from "../sql/wsRows";
|
|
|
5
5
|
export declare class WsStmt2 implements WsStmt {
|
|
6
6
|
private _wsClient;
|
|
7
7
|
private _stmt_id;
|
|
8
|
-
private _query_id;
|
|
9
8
|
private _precision;
|
|
10
9
|
private fields?;
|
|
11
10
|
private lastAffected;
|
|
@@ -16,21 +15,30 @@ export declare class WsStmt2 implements WsStmt {
|
|
|
16
15
|
private _toBeBindColCount;
|
|
17
16
|
private _toBeBindTableNameIndex;
|
|
18
17
|
private _isInsert;
|
|
18
|
+
private _savedSql;
|
|
19
|
+
private _savedBindBytes;
|
|
19
20
|
private constructor();
|
|
20
21
|
static newStmt(wsClient: WsClient, precision?: number, reqId?: number): Promise<WsStmt>;
|
|
21
22
|
private init;
|
|
22
|
-
|
|
23
|
+
private doInit;
|
|
23
24
|
prepare(sql: string): Promise<void>;
|
|
25
|
+
private doPrepare;
|
|
24
26
|
setTableName(tableName: string): Promise<void>;
|
|
25
27
|
setTags(paramsArray: StmtBindParams): Promise<void>;
|
|
26
28
|
newStmtParam(): StmtBindParams;
|
|
27
29
|
bind(paramsArray: StmtBindParams): Promise<void>;
|
|
28
30
|
batch(): Promise<void>;
|
|
29
31
|
exec(): Promise<void>;
|
|
30
|
-
private
|
|
31
|
-
|
|
32
|
+
private doSendBindBytes;
|
|
33
|
+
private doExec;
|
|
32
34
|
resultSet(): Promise<WSRows>;
|
|
35
|
+
private doResult;
|
|
33
36
|
close(): Promise<void>;
|
|
37
|
+
private cleanup;
|
|
38
|
+
private buildBindBytes;
|
|
39
|
+
private recover;
|
|
40
|
+
getStmtId(): bigint | undefined | null;
|
|
41
|
+
getLastAffected(): number | null | undefined;
|
|
34
42
|
private execute;
|
|
35
43
|
private sendBinaryMsg;
|
|
36
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsStmt2.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsStmt2.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAS9C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAOhD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"wsStmt2.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsStmt2.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAS9C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAOhD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAWvC,qBAAa,OAAQ,YAAW,MAAM;IAClC,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,UAAU,CAAiC;IACnD,OAAO,CAAC,MAAM,CAAC,CAA0C;IACzD,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,cAAc,CAAyB;IAC/C,OAAO,CAAC,iBAAiB,CAAY;IACrC,OAAO,CAAC,kBAAkB,CAAc;IACxC,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,uBAAuB,CAA4B;IAC3D,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,eAAe,CAA0B;IAEjD,OAAO;WAYM,OAAO,CAChB,QAAQ,EAAE,QAAQ,EAClB,SAAS,CAAC,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC;YAUJ,IAAI;YAwBJ,MAAM;IAYd,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAY3B,SAAS;IA4CjB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB9C,OAAO,CAAC,WAAW,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAezD,YAAY,IAAI,cAAc;IAiBxB,IAAI,CAAC,WAAW,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAsEhD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YAyCb,eAAe;YAKf,MAAM;IAWd,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;YAapB,QAAQ;IAkBhB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAiB5B,OAAO,CAAC,OAAO;IAUf,OAAO,CAAC,cAAc;YAqBR,OAAO;IAwDrB,SAAS,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;IAItC,eAAe,IAAI,MAAM,GAAG,IAAI,GAAG,SAAS;YAI9B,OAAO;YAiCP,aAAa;CAmB9B"}
|
package/lib/src/stmt/wsStmt2.js
CHANGED
|
@@ -14,6 +14,14 @@ const wsParams2_1 = require("./wsParams2");
|
|
|
14
14
|
const wsTableInfo_1 = require("./wsTableInfo");
|
|
15
15
|
const wsRows_1 = require("../sql/wsRows");
|
|
16
16
|
const FieldBindParams_1 = require("./FieldBindParams");
|
|
17
|
+
var StmtStep;
|
|
18
|
+
(function (StmtStep) {
|
|
19
|
+
StmtStep[StmtStep["INIT"] = 0] = "INIT";
|
|
20
|
+
StmtStep[StmtStep["PREPARE"] = 1] = "PREPARE";
|
|
21
|
+
StmtStep[StmtStep["BIND"] = 2] = "BIND";
|
|
22
|
+
StmtStep[StmtStep["EXEC"] = 3] = "EXEC";
|
|
23
|
+
StmtStep[StmtStep["RESULT"] = 4] = "RESULT";
|
|
24
|
+
})(StmtStep || (StmtStep = {}));
|
|
17
25
|
class WsStmt2 {
|
|
18
26
|
constructor(wsClient, precision) {
|
|
19
27
|
this._precision = constant_1.PrecisionLength["ms"];
|
|
@@ -30,11 +38,11 @@ class WsStmt2 {
|
|
|
30
38
|
}
|
|
31
39
|
static async newStmt(wsClient, precision, reqId) {
|
|
32
40
|
try {
|
|
33
|
-
|
|
41
|
+
const wsStmt = new WsStmt2(wsClient, precision);
|
|
34
42
|
return await wsStmt.init(reqId);
|
|
35
43
|
}
|
|
36
44
|
catch (e) {
|
|
37
|
-
log_1.default.error(`
|
|
45
|
+
log_1.default.error(`WsStmt2 init failed, ${e.code}, ${e.message}`);
|
|
38
46
|
throw e;
|
|
39
47
|
}
|
|
40
48
|
}
|
|
@@ -45,29 +53,45 @@ class WsStmt2 {
|
|
|
45
53
|
await this._wsClient.connect();
|
|
46
54
|
await this._wsClient.checkVersion();
|
|
47
55
|
}
|
|
48
|
-
|
|
49
|
-
action: "stmt2_init",
|
|
50
|
-
args: {
|
|
51
|
-
req_id: reqid_1.ReqId.getReqID(reqId),
|
|
52
|
-
single_stb_insert: true,
|
|
53
|
-
single_table_bind_once: true,
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
await this.execute(queryMsg);
|
|
56
|
+
await this.doInit(reqId);
|
|
57
57
|
return this;
|
|
58
58
|
}
|
|
59
59
|
catch (e) {
|
|
60
|
-
|
|
60
|
+
if (this._wsClient.isNetworkError(e)) {
|
|
61
|
+
await this.recover(StmtStep.INIT);
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
log_1.default.error(`stmt2 init failed, ${e.code}, ${e.message}`);
|
|
61
65
|
throw e;
|
|
62
66
|
}
|
|
63
67
|
}
|
|
64
|
-
throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_CONNECTION_CLOSED, "
|
|
68
|
+
throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_CONNECTION_CLOSED, "stmt2 connect closed");
|
|
65
69
|
}
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
async doInit(reqId) {
|
|
71
|
+
const msg = {
|
|
72
|
+
action: "stmt2_init",
|
|
73
|
+
args: {
|
|
74
|
+
req_id: reqid_1.ReqId.getReqID(reqId),
|
|
75
|
+
single_stb_insert: true,
|
|
76
|
+
single_table_bind_once: true,
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
await this.execute(msg);
|
|
68
80
|
}
|
|
69
81
|
async prepare(sql) {
|
|
70
|
-
|
|
82
|
+
this._savedSql = sql;
|
|
83
|
+
try {
|
|
84
|
+
await this.doPrepare(sql);
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
if (!this._wsClient.isNetworkError(err)) {
|
|
88
|
+
throw err;
|
|
89
|
+
}
|
|
90
|
+
await this.recover(StmtStep.PREPARE);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async doPrepare(sql) {
|
|
94
|
+
const msg = {
|
|
71
95
|
action: "stmt2_prepare",
|
|
72
96
|
args: {
|
|
73
97
|
req_id: reqid_1.ReqId.getReqID(),
|
|
@@ -76,14 +100,15 @@ class WsStmt2 {
|
|
|
76
100
|
get_fields: true,
|
|
77
101
|
},
|
|
78
102
|
};
|
|
79
|
-
|
|
103
|
+
const resp = await this.execute(msg);
|
|
104
|
+
if (!resp) {
|
|
105
|
+
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "stmt2_prepare response is empty");
|
|
106
|
+
}
|
|
80
107
|
if (this._isInsert && this.fields) {
|
|
81
|
-
this._precision = this.fields[0].precision
|
|
82
|
-
? this.fields[0].precision
|
|
83
|
-
: 0;
|
|
108
|
+
this._precision = this.fields[0].precision ? this.fields[0].precision : 0;
|
|
84
109
|
this._toBeBindColCount = 0;
|
|
85
110
|
this._toBeBindTagCount = 0;
|
|
86
|
-
this.fields
|
|
111
|
+
this.fields.forEach((field, index) => {
|
|
87
112
|
if (field.bind_type == constant_1.FieldBindType.TAOS_FIELD_TBNAME) {
|
|
88
113
|
this._toBeBindTableNameIndex = index;
|
|
89
114
|
}
|
|
@@ -96,7 +121,7 @@ class WsStmt2 {
|
|
|
96
121
|
});
|
|
97
122
|
}
|
|
98
123
|
else {
|
|
99
|
-
if (resp
|
|
124
|
+
if (resp.fields_count && resp.fields_count > 0) {
|
|
100
125
|
this._stmtTableInfoList = [this._currentTableInfo];
|
|
101
126
|
this._toBeBindColCount = resp.fields_count;
|
|
102
127
|
}
|
|
@@ -109,7 +134,7 @@ class WsStmt2 {
|
|
|
109
134
|
if (!tableName || tableName.length === 0) {
|
|
110
135
|
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "Table name cannot be empty");
|
|
111
136
|
}
|
|
112
|
-
|
|
137
|
+
const tableInfo = this._stmtTableInfo.get(tableName);
|
|
113
138
|
if (!tableInfo) {
|
|
114
139
|
this._currentTableInfo = new wsTableInfo_1.TableInfo(tableName);
|
|
115
140
|
this._stmtTableInfo.set(tableName, this._currentTableInfo);
|
|
@@ -144,22 +169,20 @@ class WsStmt2 {
|
|
|
144
169
|
if (!paramsArray || !this._stmt_id || !paramsArray._fieldParams) {
|
|
145
170
|
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "Bind paramArray is invalid!");
|
|
146
171
|
}
|
|
147
|
-
if (this._isInsert &&
|
|
148
|
-
this.fields &&
|
|
149
|
-
paramsArray.getBindCount() == this.fields.length) {
|
|
172
|
+
if (this._isInsert && this.fields && paramsArray.getBindCount() == this.fields.length) {
|
|
150
173
|
const tableNameIndex = this._toBeBindTableNameIndex;
|
|
151
174
|
if (tableNameIndex === null || tableNameIndex === undefined) {
|
|
152
175
|
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "Table name index is null or undefined!");
|
|
153
176
|
}
|
|
154
177
|
const paramsCount = paramsArray._fieldParams[0].params.length;
|
|
155
178
|
for (let i = 0; i < paramsCount; i++) {
|
|
156
|
-
|
|
179
|
+
const tableName = paramsArray._fieldParams[tableNameIndex].params[i];
|
|
157
180
|
await this.setTableName(tableName);
|
|
158
181
|
for (let j = 0; j < paramsArray._fieldParams.length; j++) {
|
|
159
182
|
if (j == tableNameIndex) {
|
|
160
183
|
continue;
|
|
161
184
|
}
|
|
162
|
-
|
|
185
|
+
const fieldParam = paramsArray._fieldParams[j];
|
|
163
186
|
if (this.fields[j].bind_type == constant_1.FieldBindType.TAOS_FIELD_TAG) {
|
|
164
187
|
if (!this._currentTableInfo.tags) {
|
|
165
188
|
this._currentTableInfo.tags = new wsParams2_1.Stmt2BindParams(this._toBeBindTagCount, this._precision, this.fields);
|
|
@@ -187,74 +210,172 @@ class WsStmt2 {
|
|
|
187
210
|
if (!this._currentTableInfo) {
|
|
188
211
|
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "table info is empty!");
|
|
189
212
|
}
|
|
190
|
-
|
|
213
|
+
const params = this._currentTableInfo.getParams();
|
|
191
214
|
if (!params) {
|
|
192
215
|
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "Bind params is empty!");
|
|
193
216
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
217
|
+
const bytes = (0, wsProto_1.stmt2BinaryBlockEncode)(BigInt(reqid_1.ReqId.getReqID()), this._stmtTableInfoList, this._stmt_id, this._toBeBindTableNameIndex, this._toBeBindTagCount, this._toBeBindColCount);
|
|
218
|
+
this._savedBindBytes = bytes;
|
|
219
|
+
try {
|
|
220
|
+
await this.doSendBindBytes(bytes);
|
|
221
|
+
await this.doExec();
|
|
222
|
+
}
|
|
223
|
+
catch (err) {
|
|
224
|
+
if (!this._wsClient.isNetworkError(err)) {
|
|
225
|
+
throw err;
|
|
226
|
+
}
|
|
227
|
+
await this.recover(StmtStep.EXEC);
|
|
228
|
+
}
|
|
229
|
+
finally {
|
|
230
|
+
if (this._isInsert) {
|
|
231
|
+
this.cleanup({ keepSavedSql: true });
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
async doSendBindBytes(bytes) {
|
|
236
|
+
const reqId = new DataView(bytes).getBigUint64(0, true);
|
|
237
|
+
await this.sendBinaryMsg(reqId, "stmt2_bind", bytes);
|
|
238
|
+
}
|
|
239
|
+
async doExec() {
|
|
240
|
+
const msg = {
|
|
198
241
|
action: "stmt2_exec",
|
|
199
242
|
args: {
|
|
200
243
|
req_id: reqid_1.ReqId.getReqID(),
|
|
201
244
|
stmt_id: this._stmt_id,
|
|
202
245
|
},
|
|
203
246
|
};
|
|
204
|
-
await this.execute(
|
|
205
|
-
this.cleanup();
|
|
206
|
-
}
|
|
207
|
-
cleanup() {
|
|
208
|
-
this._stmtTableInfo.clear();
|
|
209
|
-
this._stmtTableInfoList = [];
|
|
210
|
-
this._currentTableInfo = new wsTableInfo_1.TableInfo();
|
|
211
|
-
}
|
|
212
|
-
getLastAffected() {
|
|
213
|
-
return this.lastAffected;
|
|
247
|
+
await this.execute(msg);
|
|
214
248
|
}
|
|
215
249
|
async resultSet() {
|
|
216
|
-
|
|
250
|
+
try {
|
|
251
|
+
return await this.doResult();
|
|
252
|
+
}
|
|
253
|
+
catch (err) {
|
|
254
|
+
if (!this._wsClient.isNetworkError(err)) {
|
|
255
|
+
throw err;
|
|
256
|
+
}
|
|
257
|
+
return await this.recover(StmtStep.RESULT);
|
|
258
|
+
}
|
|
259
|
+
finally {
|
|
260
|
+
this.cleanup({ keepSavedSql: true });
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
async doResult() {
|
|
264
|
+
const msg = {
|
|
217
265
|
action: "stmt2_result",
|
|
218
266
|
args: {
|
|
219
267
|
req_id: reqid_1.ReqId.getReqID(),
|
|
220
268
|
stmt_id: this._stmt_id,
|
|
221
269
|
},
|
|
222
270
|
};
|
|
223
|
-
|
|
271
|
+
const resp = await this.execute(msg);
|
|
224
272
|
if (!resp) {
|
|
225
273
|
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "ResultSet response is empty!");
|
|
226
274
|
}
|
|
227
275
|
return new wsRows_1.WSRows(this._wsClient, resp);
|
|
228
276
|
}
|
|
229
277
|
async close() {
|
|
230
|
-
|
|
278
|
+
const msg = {
|
|
231
279
|
action: "stmt2_close",
|
|
232
280
|
args: {
|
|
233
281
|
req_id: reqid_1.ReqId.getReqID(),
|
|
234
282
|
stmt_id: this._stmt_id,
|
|
235
283
|
},
|
|
236
284
|
};
|
|
237
|
-
|
|
285
|
+
try {
|
|
286
|
+
await this.execute(msg);
|
|
287
|
+
}
|
|
288
|
+
catch (err) {
|
|
289
|
+
log_1.default.warn("stmt2 close failed: " + err.message);
|
|
290
|
+
}
|
|
291
|
+
finally {
|
|
292
|
+
this.cleanup();
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
cleanup(opts) {
|
|
296
|
+
this._stmtTableInfo.clear();
|
|
297
|
+
this._stmtTableInfoList = [];
|
|
298
|
+
this._currentTableInfo = new wsTableInfo_1.TableInfo();
|
|
299
|
+
if (!opts?.keepSavedSql) {
|
|
300
|
+
this._savedSql = undefined;
|
|
301
|
+
}
|
|
302
|
+
this._savedBindBytes = undefined;
|
|
303
|
+
}
|
|
304
|
+
buildBindBytes() {
|
|
305
|
+
if (this._savedBindBytes === undefined) {
|
|
306
|
+
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "bind bytes are missing for stmt2 rebuild");
|
|
307
|
+
}
|
|
308
|
+
if (this._stmt_id === undefined || this._stmt_id === null) {
|
|
309
|
+
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "stmt_id is missing for stmt2 rebuild");
|
|
310
|
+
}
|
|
311
|
+
const bytes = this._savedBindBytes.slice(0);
|
|
312
|
+
const view = new DataView(bytes);
|
|
313
|
+
view.setBigUint64(0, BigInt(reqid_1.ReqId.getReqID()), true);
|
|
314
|
+
view.setBigUint64(8, this._stmt_id, true);
|
|
315
|
+
return bytes;
|
|
316
|
+
}
|
|
317
|
+
async recover(failedStep) {
|
|
318
|
+
const retries = this._wsClient.getReconnectRetries();
|
|
319
|
+
const maxAttempts = retries > 0 ? retries : 5;
|
|
320
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
321
|
+
try {
|
|
322
|
+
await this._wsClient.waitForReady();
|
|
323
|
+
await this.doInit();
|
|
324
|
+
if (failedStep === StmtStep.INIT) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
if (this._savedSql === undefined) {
|
|
328
|
+
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "prepare SQL is missing for stmt2 rebuild");
|
|
329
|
+
}
|
|
330
|
+
await this.doPrepare(this._savedSql);
|
|
331
|
+
if (failedStep === StmtStep.PREPARE) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
await this.doSendBindBytes(this.buildBindBytes());
|
|
335
|
+
if (failedStep === StmtStep.BIND) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
await this.doExec();
|
|
339
|
+
if (failedStep === StmtStep.EXEC) {
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
return await this.doResult();
|
|
343
|
+
}
|
|
344
|
+
catch (err) {
|
|
345
|
+
if (!this._wsClient.isNetworkError(err)) {
|
|
346
|
+
throw err;
|
|
347
|
+
}
|
|
348
|
+
if (attempt === maxAttempts) {
|
|
349
|
+
const recoverError = new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `stmt2 recover exceeded max attempts (${maxAttempts}) at step ${StmtStep[failedStep]}: ${err?.message || err}`);
|
|
350
|
+
recoverError.cause = err;
|
|
351
|
+
throw recoverError;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `stmt2 recover exited unexpectedly at step ${StmtStep[failedStep]}`);
|
|
356
|
+
}
|
|
357
|
+
getStmtId() {
|
|
358
|
+
return this._stmt_id;
|
|
359
|
+
}
|
|
360
|
+
getLastAffected() {
|
|
361
|
+
return this.lastAffected;
|
|
238
362
|
}
|
|
239
363
|
async execute(stmtMsg, register = true) {
|
|
240
364
|
try {
|
|
241
|
-
|
|
242
|
-
throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_CONNECTION_CLOSED, "websocket connect has closed!");
|
|
243
|
-
}
|
|
244
|
-
let reqMsg = json_bigint_1.default.stringify(stmtMsg);
|
|
365
|
+
const reqMsg = json_bigint_1.default.stringify(stmtMsg);
|
|
245
366
|
if (register) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
if (resp.stmt_id) {
|
|
367
|
+
const result = await this._wsClient.exec(reqMsg, false);
|
|
368
|
+
const resp = new wsProto_1.WsStmtQueryResponse(result);
|
|
369
|
+
if (resp.stmt_id !== undefined && resp.stmt_id !== null) {
|
|
249
370
|
this._stmt_id = resp.stmt_id;
|
|
250
371
|
}
|
|
251
|
-
if (resp.affected) {
|
|
372
|
+
if (resp.affected !== undefined && resp.affected !== null) {
|
|
252
373
|
this.lastAffected = resp.affected;
|
|
253
374
|
}
|
|
254
|
-
if (resp.fields) {
|
|
375
|
+
if (resp.fields !== undefined && resp.fields !== null) {
|
|
255
376
|
this.fields = resp.fields;
|
|
256
377
|
}
|
|
257
|
-
if (resp.is_insert) {
|
|
378
|
+
if (resp.is_insert !== undefined && resp.is_insert !== null) {
|
|
258
379
|
this._isInsert = resp.is_insert;
|
|
259
380
|
}
|
|
260
381
|
return resp;
|
|
@@ -268,15 +389,12 @@ class WsStmt2 {
|
|
|
268
389
|
}
|
|
269
390
|
}
|
|
270
391
|
async sendBinaryMsg(reqId, action, message) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
let result = await this._wsClient.sendBinaryMsg(reqId, action, message, false);
|
|
275
|
-
let resp = new wsProto_1.WsStmtQueryResponse(result);
|
|
276
|
-
if (resp.stmt_id) {
|
|
392
|
+
const result = await this._wsClient.sendBinaryMsg(reqId, action, message, false);
|
|
393
|
+
const resp = new wsProto_1.WsStmtQueryResponse(result);
|
|
394
|
+
if (resp.stmt_id !== undefined && resp.stmt_id !== null) {
|
|
277
395
|
this._stmt_id = resp.stmt_id;
|
|
278
396
|
}
|
|
279
|
-
if (resp.affected) {
|
|
397
|
+
if (resp.affected !== undefined && resp.affected !== null) {
|
|
280
398
|
this.lastAffected = resp.affected;
|
|
281
399
|
}
|
|
282
400
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsTableInfo.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsTableInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"wsTableInfo.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsTableInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,qBAAa,SAAS;IAClB,IAAI,EAAE,UAAU,GAAG,SAAS,GAAG,IAAI,CAAC;IACpC,IAAI,EAAE,cAAc,GAAG,SAAS,GAAG,IAAI,CAAC;IACxC,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,MAAM,EAAE,MAAM,CAAK;IACnB,WAAW,cAAqB;gBAEpB,IAAI,CAAC,EAAE,MAAM;IAOlB,YAAY,IAAI,UAAU,GAAG,SAAS,GAAG,IAAI;IAI7C,kBAAkB,IAAI,MAAM;IAI5B,OAAO,IAAI,cAAc,GAAG,SAAS,GAAG,IAAI;IAI5C,SAAS,IAAI,cAAc,GAAG,SAAS,GAAG,IAAI;IAI9C,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAYjC,OAAO,CAAC,WAAW,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAWnD,SAAS,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAS7D"}
|
package/lib/src/tmq/config.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/tmq/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/tmq/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAA0B,MAAM,eAAe,CAAC;AAG5D,qBAAa,SAAS;IAClB,GAAG,EAAE,GAAG,GAAG,IAAI,CAAQ;IACvB,MAAM,EAAE,GAAG,GAAG,IAAI,CAAQ;IAC1B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC3B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC/B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC5B,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,CAAS;IACxB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;gBAEnB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC;CA4EzC"}
|
package/lib/src/tmq/config.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TmqConfig = void 0;
|
|
4
|
+
const dsn_1 = require("../common/dsn");
|
|
4
5
|
const constant_1 = require("./constant");
|
|
5
6
|
class TmqConfig {
|
|
6
7
|
constructor(wsConfig) {
|
|
7
|
-
this.
|
|
8
|
-
this.
|
|
8
|
+
this.dsn = null;
|
|
9
|
+
this.sqlDsn = null;
|
|
9
10
|
this.user = null;
|
|
10
11
|
this.password = null;
|
|
11
12
|
this.token = null;
|
|
@@ -14,12 +15,13 @@ class TmqConfig {
|
|
|
14
15
|
this.offset_rest = null;
|
|
15
16
|
this.auto_commit = true;
|
|
16
17
|
this.auto_commit_interval_ms = 5 * 1000;
|
|
17
|
-
this.timeout =
|
|
18
|
+
this.timeout = 60000;
|
|
18
19
|
this.otherConfigs = new Map();
|
|
19
20
|
for (const [key, value] of wsConfig) {
|
|
20
21
|
switch (key) {
|
|
21
22
|
case constant_1.TMQConstants.WS_URL:
|
|
22
|
-
this.
|
|
23
|
+
this.dsn = (0, dsn_1.parse)(value);
|
|
24
|
+
this.dsn.endpoint = dsn_1.WS_TMQ_ENDPOINT;
|
|
23
25
|
break;
|
|
24
26
|
case constant_1.TMQConstants.CONNECT_USER:
|
|
25
27
|
this.user = value;
|
|
@@ -53,35 +55,33 @@ class TmqConfig {
|
|
|
53
55
|
this.otherConfigs.set(key, value);
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
|
-
if (this.
|
|
58
|
+
if (this.dsn) {
|
|
57
59
|
if (this.user) {
|
|
58
|
-
this.
|
|
60
|
+
this.dsn.username = this.user;
|
|
59
61
|
}
|
|
60
62
|
else {
|
|
61
|
-
this.user = this.
|
|
63
|
+
this.user = this.dsn.username;
|
|
62
64
|
}
|
|
63
65
|
if (this.password) {
|
|
64
|
-
this.
|
|
66
|
+
this.dsn.password = this.password;
|
|
65
67
|
}
|
|
66
68
|
else {
|
|
67
|
-
this.password = this.
|
|
69
|
+
this.password = this.dsn.password;
|
|
68
70
|
}
|
|
69
71
|
if (this.token) {
|
|
70
|
-
this.
|
|
72
|
+
this.dsn.params.set("bearer_token", this.token);
|
|
71
73
|
}
|
|
72
74
|
else {
|
|
73
|
-
const bearerToken = this.
|
|
75
|
+
const bearerToken = this.dsn.params.get("bearer_token");
|
|
74
76
|
if (bearerToken) {
|
|
75
77
|
this.token = bearerToken;
|
|
76
78
|
this.otherConfigs.set(constant_1.TMQConstants.CONNECT_TOKEN, bearerToken);
|
|
77
79
|
}
|
|
78
80
|
else {
|
|
79
|
-
this.
|
|
81
|
+
this.dsn.params.delete("bearer_token");
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
|
-
this.
|
|
83
|
-
this.sql_url.pathname = "/ws";
|
|
84
|
-
this.url.pathname = "/rest/tmq";
|
|
84
|
+
this.sqlDsn = new dsn_1.Dsn(this.dsn.scheme, this.dsn.username, this.dsn.password, this.dsn.addresses, this.dsn.database, this.dsn.params);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
}
|
package/lib/src/tmq/wsTmq.d.ts
CHANGED
|
@@ -2,13 +2,16 @@ import { TaosResult } from "../common/taosResult";
|
|
|
2
2
|
import { TopicPartition } from "./tmqResponse";
|
|
3
3
|
export declare class WsConsumer {
|
|
4
4
|
private _wsClient;
|
|
5
|
-
private
|
|
5
|
+
private _config;
|
|
6
6
|
private _topics?;
|
|
7
7
|
private _commitTime?;
|
|
8
8
|
private _lastMessageID?;
|
|
9
9
|
private constructor();
|
|
10
10
|
private init;
|
|
11
11
|
static newConsumer(wsConfig: Map<string, any>): Promise<WsConsumer>;
|
|
12
|
+
private bindSessionRecoveryHook;
|
|
13
|
+
private buildSubscribeMessage;
|
|
14
|
+
private recoverSessionContext;
|
|
12
15
|
subscribe(topics: Array<string>, reqId?: number): Promise<void>;
|
|
13
16
|
unsubscribe(reqId?: number): Promise<void>;
|
|
14
17
|
poll(timeoutMs: number, reqId?: number): Promise<Map<string, TaosResult>>;
|
|
@@ -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;AAOlD,OAAO,EAMH,cAAc,EAGjB,MAAM,eAAe,CAAC;AAOvB,qBAAa,UAAU;IACnB,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,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,EAGjB,MAAM,eAAe,CAAC;AAOvB,qBAAa,UAAU;IACnB,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,OAAO,CAAC,CAAW;IAC3B,OAAO,CAAC,WAAW,CAAC,CAAS;IAC7B,OAAO,CAAC,cAAc,CAAC,CAAS;IAEhC,OAAO;YAgBO,IAAI;WAyBL,WAAW,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IAWzE,OAAO,CAAC,uBAAuB;IAM/B,OAAO,CAAC,qBAAqB;YA0Bf,qBAAqB;IAa7B,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAa/D,WAAW,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAW1C,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAgBzE,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAWpD,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;YAK9C,QAAQ;IAWhB,SAAS,CACX,UAAU,EAAE,KAAK,CAAC,cAAc,CAAC,EACjC,KAAK,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAgC3B,aAAa,CAAC,UAAU,EAAE,KAAK,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAehF,YAAY,CAAC,SAAS,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBtE,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;IAU3D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAId,cAAc;YA+Bd,QAAQ;YAsCR,iBAAiB;IAgBzB,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;YAoBrD,gBAAgB;CAmCjC"}
|