@tdengine/websocket 3.0.0 → 3.1.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/example/basicSchemaless.d.ts +2 -0
- package/lib/example/basicSchemaless.d.ts.map +1 -0
- package/lib/example/basicSchemaless.js +47 -0
- package/lib/example/basicSql.d.ts +2 -0
- package/lib/example/basicSql.d.ts.map +1 -0
- package/lib/example/basicSql.js +52 -0
- package/lib/example/basicStmt.d.ts +2 -0
- package/lib/example/basicStmt.d.ts.map +1 -0
- package/lib/example/basicStmt.js +58 -0
- package/lib/example/basicTmq.d.ts +2 -0
- package/lib/example/basicTmq.d.ts.map +1 -0
- package/lib/example/basicTmq.js +71 -0
- package/lib/index.d.ts +26 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +41 -0
- package/lib/src/client/wsClient.d.ts +22 -0
- package/lib/src/client/wsClient.d.ts.map +1 -0
- package/lib/src/client/wsClient.js +253 -0
- package/lib/src/client/wsConnector.d.ts +17 -0
- package/lib/src/client/wsConnector.d.ts.map +1 -0
- package/lib/src/client/wsConnector.js +140 -0
- package/lib/src/client/wsConnectorPool.d.ts +13 -0
- package/lib/src/client/wsConnectorPool.d.ts.map +1 -0
- package/lib/src/client/wsConnectorPool.js +107 -0
- package/lib/src/client/wsEventCallback.d.ts +22 -0
- package/lib/src/client/wsEventCallback.d.ts.map +1 -0
- package/lib/src/client/wsEventCallback.js +97 -0
- package/lib/src/client/wsResponse.d.ts +66 -0
- package/lib/src/client/wsResponse.d.ts.map +1 -0
- package/lib/src/client/wsResponse.js +76 -0
- package/lib/src/common/config.d.ts +22 -0
- package/lib/src/common/config.d.ts.map +1 -0
- package/lib/src/common/config.js +45 -0
- package/lib/src/common/constant.d.ts +13 -0
- package/lib/src/common/constant.d.ts.map +1 -0
- package/{src/constant.ts → lib/src/common/constant.js} +25 -24
- package/lib/src/common/log.d.ts +5 -0
- package/lib/src/common/log.d.ts.map +1 -0
- package/lib/src/common/log.js +40 -0
- package/lib/src/common/reqid.d.ts +8 -0
- package/lib/src/common/reqid.d.ts.map +1 -0
- package/lib/src/common/reqid.js +59 -0
- package/lib/src/common/taosResult.d.ts +51 -0
- package/lib/src/common/taosResult.d.ts.map +1 -0
- package/lib/src/common/taosResult.js +419 -0
- package/lib/src/common/ut8Helper.d.ts +2 -0
- package/lib/src/common/ut8Helper.d.ts.map +1 -0
- package/{src/ut8Helper.ts → lib/src/common/ut8Helper.js} +22 -21
- package/lib/src/common/utils.d.ts +5 -0
- package/lib/src/common/utils.d.ts.map +1 -0
- package/lib/src/common/utils.js +33 -0
- package/lib/src/common/wsError.d.ts +29 -0
- package/lib/src/common/wsError.d.ts.map +1 -0
- package/lib/src/common/wsError.js +51 -0
- package/{src/wsOptions.ts → lib/src/common/wsOptions.d.ts} +4 -2
- package/lib/src/common/wsOptions.d.ts.map +1 -0
- package/lib/src/common/wsOptions.js +2 -0
- package/lib/src/index.d.ts +9 -0
- package/lib/src/index.d.ts.map +1 -0
- package/lib/src/index.js +58 -0
- package/lib/src/sql/wsProto.d.ts +26 -0
- package/lib/src/sql/wsProto.d.ts.map +1 -0
- package/lib/src/sql/wsProto.js +19 -0
- package/lib/src/sql/wsRows.d.ts +16 -0
- package/lib/src/sql/wsRows.d.ts.map +1 -0
- package/lib/src/sql/wsRows.js +76 -0
- package/lib/src/sql/wsSql.d.ts +24 -0
- package/lib/src/sql/wsSql.d.ts.map +1 -0
- package/lib/src/sql/wsSql.js +164 -0
- package/lib/src/stmt/wsParams.d.ts +41 -0
- package/lib/src/stmt/wsParams.d.ts.map +1 -0
- package/lib/src/stmt/wsParams.js +428 -0
- package/lib/src/stmt/wsProto.d.ts +27 -0
- package/lib/src/stmt/wsProto.d.ts.map +1 -0
- package/lib/src/stmt/wsProto.js +67 -0
- package/lib/src/stmt/wsStmt.d.ts +30 -0
- package/lib/src/stmt/wsStmt.d.ts.map +1 -0
- package/lib/src/stmt/wsStmt.js +207 -0
- package/lib/src/tmq/config.d.ts +14 -0
- package/lib/src/tmq/config.d.ts.map +1 -0
- package/lib/src/tmq/config.js +42 -0
- package/lib/src/tmq/constant.d.ts +85 -0
- package/lib/src/tmq/constant.d.ts.map +1 -0
- package/lib/src/tmq/constant.js +89 -0
- package/lib/src/tmq/tmqResponse.d.ts +80 -0
- package/lib/src/tmq/tmqResponse.d.ts.map +1 -0
- package/lib/src/tmq/tmqResponse.js +204 -0
- package/lib/src/tmq/wsTmq.d.ts +32 -0
- package/lib/src/tmq/wsTmq.d.ts.map +1 -0
- package/lib/src/tmq/wsTmq.js +316 -0
- package/lib/test/bulkPulling/queryTables.test.d.ts +2 -0
- package/lib/test/bulkPulling/queryTables.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/queryTables.test.js +297 -0
- package/lib/test/bulkPulling/schemaless.test.d.ts +2 -0
- package/lib/test/bulkPulling/schemaless.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/schemaless.test.js +94 -0
- package/lib/test/bulkPulling/sql.test.d.ts +2 -0
- package/lib/test/bulkPulling/sql.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/sql.test.js +124 -0
- package/lib/test/bulkPulling/stmt.func.test.d.ts +2 -0
- package/lib/test/bulkPulling/stmt.func.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/stmt.func.test.js +381 -0
- package/lib/test/bulkPulling/stmt.type.test.d.ts +2 -0
- package/lib/test/bulkPulling/stmt.type.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/stmt.type.test.js +273 -0
- package/lib/test/bulkPulling/tmq.test.d.ts +2 -0
- package/lib/test/bulkPulling/tmq.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/tmq.test.js +177 -0
- package/lib/test/bulkPulling/wsConnectPool.test.d.ts +2 -0
- package/lib/test/bulkPulling/wsConnectPool.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/wsConnectPool.test.js +129 -0
- package/lib/test/utils.d.ts +18 -0
- package/lib/test/utils.d.ts.map +1 -0
- package/lib/test/utils.js +318 -0
- package/package.json +27 -14
- package/readme.md +302 -0
- package/README.md +0 -59
- package/dist/browser/index.js +0 -778
- package/dist/main/index.js +0 -711
- package/dist/main/index.js.map +0 -1
- package/dist/module/index.mjs +0 -704
- package/dist/module/index.mjs.map +0 -1
- package/dist/types.d.ts +0 -103
- package/dist/types.d.ts.map +0 -1
- package/example/basicUsageAsync.ts +0 -48
- package/example/basicUsagePrimse.ts +0 -43
- package/example/cloudUsage.ts +0 -55
- package/example/continousConnectAndVersion.ts +0 -16
- package/example/test.mjs +0 -51
- package/index.ts +0 -7
- package/jest.config.js +0 -8
- package/src/taosResult.ts +0 -269
- package/src/tdengineWebsocket.ts +0 -39
- package/src/wsClient.ts +0 -196
- package/src/wsError.ts +0 -5
- package/src/wsQuery.ts +0 -30
- package/src/wsQueryInterface.ts +0 -212
- package/src/wsQueryResponse.ts +0 -112
- package/tdengine-websocket-3.0.0.tgz +0 -0
- package/test/bulkPulling/connect.test.ts +0 -27
- package/test/bulkPulling/queryTables.test.ts +0 -274
- package/test/bulkPulling/version.test.ts +0 -19
- package/test/utils.ts +0 -235
- package/tsconfig.json +0 -101
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.WebSocketConnector = void 0;
|
|
7
|
+
const websocket_1 = require("websocket");
|
|
8
|
+
const wsError_1 = require("../common/wsError");
|
|
9
|
+
const wsEventCallback_1 = require("./wsEventCallback");
|
|
10
|
+
const log_1 = __importDefault(require("../common/log"));
|
|
11
|
+
const reqid_1 = require("../common/reqid");
|
|
12
|
+
class WebSocketConnector {
|
|
13
|
+
// create ws
|
|
14
|
+
constructor(url, timeout) {
|
|
15
|
+
this._timeout = 5000;
|
|
16
|
+
// return w3bsocket3
|
|
17
|
+
if (url) {
|
|
18
|
+
this._wsURL = url;
|
|
19
|
+
let origin = url.origin;
|
|
20
|
+
let pathname = url.pathname;
|
|
21
|
+
let search = url.search;
|
|
22
|
+
if (timeout) {
|
|
23
|
+
this._timeout = timeout;
|
|
24
|
+
}
|
|
25
|
+
this._wsConn = new websocket_1.w3cwebsocket(origin.concat(pathname).concat(search));
|
|
26
|
+
this._wsConn.onerror = function (err) { log_1.default.error(err.message); throw err; };
|
|
27
|
+
this._wsConn.onclose = this._onclose;
|
|
28
|
+
this._wsConn.onmessage = this._onmessage;
|
|
29
|
+
this._wsConn._binaryType = "arraybuffer";
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
throw new wsError_1.WebSocketQueryError(wsError_1.ErrorCode.ERR_INVALID_URL, "websocket URL must be defined");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async ready() {
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
let reqId = reqid_1.ReqId.getReqID();
|
|
38
|
+
wsEventCallback_1.WsEventCallback.instance().registerCallback({ action: "websocket_connection", req_id: BigInt(reqId),
|
|
39
|
+
timeout: this._timeout, id: BigInt(reqId) }, resolve, reject);
|
|
40
|
+
this._wsConn.onopen = () => {
|
|
41
|
+
log_1.default.debug("websocket connection opened");
|
|
42
|
+
wsEventCallback_1.WsEventCallback.instance().handleEventCallback({ id: BigInt(reqId), action: "websocket_connection", req_id: BigInt(reqId) }, wsEventCallback_1.OnMessageType.MESSAGE_TYPE_CONNECTION, this);
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
async _onclose(e) {
|
|
47
|
+
log_1.default.info("websocket connection closed");
|
|
48
|
+
}
|
|
49
|
+
_onmessage(event) {
|
|
50
|
+
let data = event.data;
|
|
51
|
+
log_1.default.debug("wsClient._onMessage()====" + (Object.prototype.toString.call(data)));
|
|
52
|
+
if (Object.prototype.toString.call(data) === '[object ArrayBuffer]') {
|
|
53
|
+
let id = new DataView(data, 8, 8).getBigUint64(0, true);
|
|
54
|
+
wsEventCallback_1.WsEventCallback.instance().handleEventCallback({ id: id, action: '', req_id: BigInt(0) }, wsEventCallback_1.OnMessageType.MESSAGE_TYPE_ARRAYBUFFER, data);
|
|
55
|
+
}
|
|
56
|
+
else if (Object.prototype.toString.call(data) === '[object Blob]') {
|
|
57
|
+
data.arrayBuffer().then((d) => {
|
|
58
|
+
let id = new DataView(d, 8, 8).getBigUint64(0, true);
|
|
59
|
+
wsEventCallback_1.WsEventCallback.instance().handleEventCallback({ id: id, action: '', req_id: BigInt(0) }, wsEventCallback_1.OnMessageType.MESSAGE_TYPE_BLOB, d);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
else if (Object.prototype.toString.call(data) === '[object String]') {
|
|
63
|
+
let msg = JSON.parse(data);
|
|
64
|
+
log_1.default.debug("[_onmessage.stringType]==>:" + data);
|
|
65
|
+
wsEventCallback_1.WsEventCallback.instance().handleEventCallback({ id: BigInt(0), action: msg.action, req_id: msg.req_id }, wsEventCallback_1.OnMessageType.MESSAGE_TYPE_STRING, msg);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_INVALID_MESSAGE_TYPE, `invalid message type ${Object.prototype.toString.call(data)}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
close() {
|
|
72
|
+
if (this._wsConn) {
|
|
73
|
+
this._wsConn.close();
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, "WebSocket connection is undefined.");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
readyState() {
|
|
80
|
+
return this._wsConn.readyState;
|
|
81
|
+
}
|
|
82
|
+
async sendMsgNoResp(message) {
|
|
83
|
+
log_1.default.debug("[wsClient.sendMsgNoResp()]===>" + message);
|
|
84
|
+
let msg = JSON.parse(message);
|
|
85
|
+
if (msg.args.id !== undefined) {
|
|
86
|
+
msg.args.id = BigInt(msg.args.id);
|
|
87
|
+
}
|
|
88
|
+
return new Promise((resolve, reject) => {
|
|
89
|
+
if (this._wsConn && this._wsConn.readyState > 0) {
|
|
90
|
+
this._wsConn.send(message);
|
|
91
|
+
resolve();
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
reject(new wsError_1.WebSocketQueryError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `WebSocket connection is not ready,status :${this._wsConn?.readyState}`));
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
async sendMsg(message, register = true) {
|
|
99
|
+
log_1.default.debug("[wsClient.sendMessage()]===>" + message);
|
|
100
|
+
let msg = JSON.parse(message);
|
|
101
|
+
if (msg.args.id !== undefined) {
|
|
102
|
+
msg.args.id = BigInt(msg.args.id);
|
|
103
|
+
}
|
|
104
|
+
return new Promise((resolve, reject) => {
|
|
105
|
+
if (this._wsConn && this._wsConn.readyState > 0) {
|
|
106
|
+
if (register) {
|
|
107
|
+
wsEventCallback_1.WsEventCallback.instance().registerCallback({ action: msg.action, req_id: msg.args.req_id,
|
|
108
|
+
timeout: this._timeout, id: msg.args.id === undefined ? msg.args.id : BigInt(msg.args.id) }, resolve, reject);
|
|
109
|
+
}
|
|
110
|
+
log_1.default.debug("[wsClient.sendMessage.msg]===>\n", message);
|
|
111
|
+
this._wsConn.send(message);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
reject(new wsError_1.WebSocketQueryError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `WebSocket connection is not ready,status :${this._wsConn?.readyState}`));
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
async sendBinaryMsg(reqId, action, message, register = true) {
|
|
119
|
+
return new Promise((resolve, reject) => {
|
|
120
|
+
if (this._wsConn && this._wsConn.readyState > 0) {
|
|
121
|
+
if (register) {
|
|
122
|
+
wsEventCallback_1.WsEventCallback.instance().registerCallback({ action: action, req_id: reqId,
|
|
123
|
+
timeout: this._timeout, id: reqId }, resolve, reject);
|
|
124
|
+
}
|
|
125
|
+
log_1.default.debug("[wsClient.sendBinaryMsg()]===>" + reqId, action, message.byteLength);
|
|
126
|
+
this._wsConn.send(message);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
reject(new wsError_1.WebSocketQueryError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `WebSocket connection is not ready,status :${this._wsConn?.readyState}`));
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
configTimeout(ms) {
|
|
134
|
+
this._timeout = ms;
|
|
135
|
+
}
|
|
136
|
+
getWsURL() {
|
|
137
|
+
return this._wsURL;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
exports.WebSocketConnector = WebSocketConnector;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { WebSocketConnector } from "./wsConnector";
|
|
2
|
+
export declare class WebSocketConnectionPool {
|
|
3
|
+
private static _instance?;
|
|
4
|
+
private pool;
|
|
5
|
+
private _connectionCount;
|
|
6
|
+
private readonly _maxConnections;
|
|
7
|
+
private constructor();
|
|
8
|
+
static instance(maxConnections?: number): WebSocketConnectionPool;
|
|
9
|
+
getConnection(url: URL, timeout: number | undefined | null): Promise<WebSocketConnector>;
|
|
10
|
+
releaseConnection(connector: WebSocketConnector): Promise<void>;
|
|
11
|
+
destroyed(): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=wsConnectorPool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wsConnectorPool.d.ts","sourceRoot":"","sources":["../../../src/client/wsConnectorPool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAKnD,qBAAa,uBAAuB;IAChC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAyB;IAClD,OAAO,CAAC,IAAI,CAAgD;IAC5D,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO;WAKO,QAAQ,CAAC,cAAc,GAAE,MAAW,GAAE,uBAAuB;IAOrE,aAAa,CAAC,GAAG,EAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA6BvF,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,GAAE,OAAO,CAAC,IAAI,CAAC;IA0BpE,SAAS;CAYZ"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.WebSocketConnectionPool = void 0;
|
|
7
|
+
const async_mutex_1 = require("async-mutex");
|
|
8
|
+
const wsConnector_1 = require("./wsConnector");
|
|
9
|
+
const wsError_1 = require("../common/wsError");
|
|
10
|
+
const log_1 = __importDefault(require("../common/log"));
|
|
11
|
+
const mutex = new async_mutex_1.Mutex();
|
|
12
|
+
class WebSocketConnectionPool {
|
|
13
|
+
constructor(maxConnections = -1) {
|
|
14
|
+
this.pool = new Map();
|
|
15
|
+
this._maxConnections = maxConnections;
|
|
16
|
+
this._connectionCount = 0;
|
|
17
|
+
}
|
|
18
|
+
static instance(maxConnections = -1) {
|
|
19
|
+
if (!WebSocketConnectionPool._instance) {
|
|
20
|
+
WebSocketConnectionPool._instance = new WebSocketConnectionPool(maxConnections);
|
|
21
|
+
}
|
|
22
|
+
return WebSocketConnectionPool._instance;
|
|
23
|
+
}
|
|
24
|
+
async getConnection(url, timeout) {
|
|
25
|
+
let connectAddr = url.origin.concat(url.pathname).concat(url.search);
|
|
26
|
+
let connector;
|
|
27
|
+
const unlock = await mutex.acquire();
|
|
28
|
+
try {
|
|
29
|
+
if (this.pool.has(connectAddr)) {
|
|
30
|
+
let connectors = this.pool.get(connectAddr);
|
|
31
|
+
if (connectors) {
|
|
32
|
+
if (connectors.length > 0) {
|
|
33
|
+
connector = connectors.pop();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (connector) {
|
|
38
|
+
log_1.default.debug("get connection success:", this._connectionCount);
|
|
39
|
+
return connector;
|
|
40
|
+
}
|
|
41
|
+
if (this._maxConnections != -1 && this._connectionCount > this._maxConnections) {
|
|
42
|
+
throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_ARRIVED_LIMIT, "websocket connect arrived limited:" + this._connectionCount);
|
|
43
|
+
}
|
|
44
|
+
this._connectionCount++;
|
|
45
|
+
return new wsConnector_1.WebSocketConnector(url, timeout);
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
unlock();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async releaseConnection(connector) {
|
|
52
|
+
if (connector) {
|
|
53
|
+
const unlock = await mutex.acquire();
|
|
54
|
+
try {
|
|
55
|
+
if (connector.readyState() > 0) {
|
|
56
|
+
let url = connector.getWsURL();
|
|
57
|
+
let connectAddr = url.origin.concat(url.pathname).concat(url.search);
|
|
58
|
+
let connectors = this.pool.get(connectAddr);
|
|
59
|
+
if (!connectors) {
|
|
60
|
+
connectors = new Array();
|
|
61
|
+
connectors.push(connector);
|
|
62
|
+
this.pool.set(connectAddr, connectors);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
connectors.push(connector);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
this._connectionCount--;
|
|
70
|
+
connector.close();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
unlock();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
destroyed() {
|
|
79
|
+
if (this.pool) {
|
|
80
|
+
for (let values of this.pool.values()) {
|
|
81
|
+
for (let i in values) {
|
|
82
|
+
values.pop()?.close();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
log_1.default.info("destroyed connect:" + this._connectionCount);
|
|
87
|
+
this._connectionCount = 0;
|
|
88
|
+
this.pool = new Map();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.WebSocketConnectionPool = WebSocketConnectionPool;
|
|
92
|
+
process.on('exit', (code) => {
|
|
93
|
+
log_1.default.info("begin destroy connect");
|
|
94
|
+
WebSocketConnectionPool.instance().destroyed();
|
|
95
|
+
process.exit();
|
|
96
|
+
});
|
|
97
|
+
process.on('SIGINT', () => {
|
|
98
|
+
log_1.default.info('Received SIGINT. Press Control-D to exit, begin destroy connect...');
|
|
99
|
+
WebSocketConnectionPool.instance().destroyed();
|
|
100
|
+
process.exit();
|
|
101
|
+
});
|
|
102
|
+
process.on('SIGTERM', () => {
|
|
103
|
+
log_1.default.info('Received SIGINT. Press Control-D to exit, begin destroy connect');
|
|
104
|
+
WebSocketConnectionPool.instance().destroyed();
|
|
105
|
+
process.exit();
|
|
106
|
+
});
|
|
107
|
+
// process.kill(process.pid, 'SIGINT');
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
interface MessageId {
|
|
2
|
+
action: string;
|
|
3
|
+
req_id: bigint;
|
|
4
|
+
id?: bigint;
|
|
5
|
+
timeout?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare enum OnMessageType {
|
|
8
|
+
MESSAGE_TYPE_ARRAYBUFFER = 1,
|
|
9
|
+
MESSAGE_TYPE_BLOB = 2,
|
|
10
|
+
MESSAGE_TYPE_STRING = 3,
|
|
11
|
+
MESSAGE_TYPE_CONNECTION = 4
|
|
12
|
+
}
|
|
13
|
+
export declare class WsEventCallback {
|
|
14
|
+
private static _instance?;
|
|
15
|
+
private static _msgActionRegister;
|
|
16
|
+
private constructor();
|
|
17
|
+
static instance(): WsEventCallback;
|
|
18
|
+
registerCallback(id: MessageId, res: (args: unknown) => void, rej: (reason: any) => void): Promise<void>;
|
|
19
|
+
handleEventCallback(msg: MessageId, messageType: OnMessageType, data: any): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=wsEventCallback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wsEventCallback.d.ts","sourceRoot":"","sources":["../../../src/client/wsEventCallback.ts"],"names":[],"mappings":"AAKA,UAAU,SAAS;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAC,MAAM,CAAA;CAClB;AASD,oBAAY,aAAa;IACrB,wBAAwB,IAAI;IAC5B,iBAAiB,IAAI;IACrB,mBAAmB,IAAI;IACvB,uBAAuB,IAAI;CAC9B;AAGD,qBAAa,eAAe;IACxB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAiB;IAC1C,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAA4C;IAC7E,OAAO;WAGO,QAAQ,IAAG,eAAe;IAOlC,gBAAgB,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI;IAgBxF,mBAAmB,CAAC,GAAG,EAAE,SAAS,EAAE,WAAW,EAAC,aAAa,EAAE,IAAI,EAAC,GAAG;CAqDhF"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.WsEventCallback = exports.OnMessageType = void 0;
|
|
7
|
+
const async_mutex_1 = require("async-mutex");
|
|
8
|
+
const wsError_1 = require("../common/wsError");
|
|
9
|
+
const log_1 = __importDefault(require("../common/log"));
|
|
10
|
+
var OnMessageType;
|
|
11
|
+
(function (OnMessageType) {
|
|
12
|
+
OnMessageType[OnMessageType["MESSAGE_TYPE_ARRAYBUFFER"] = 1] = "MESSAGE_TYPE_ARRAYBUFFER";
|
|
13
|
+
OnMessageType[OnMessageType["MESSAGE_TYPE_BLOB"] = 2] = "MESSAGE_TYPE_BLOB";
|
|
14
|
+
OnMessageType[OnMessageType["MESSAGE_TYPE_STRING"] = 3] = "MESSAGE_TYPE_STRING";
|
|
15
|
+
OnMessageType[OnMessageType["MESSAGE_TYPE_CONNECTION"] = 4] = "MESSAGE_TYPE_CONNECTION";
|
|
16
|
+
})(OnMessageType || (exports.OnMessageType = OnMessageType = {}));
|
|
17
|
+
const eventMutex = new async_mutex_1.Mutex();
|
|
18
|
+
class WsEventCallback {
|
|
19
|
+
constructor() {
|
|
20
|
+
}
|
|
21
|
+
static instance() {
|
|
22
|
+
if (!WsEventCallback._instance) {
|
|
23
|
+
WsEventCallback._instance = new WsEventCallback();
|
|
24
|
+
}
|
|
25
|
+
return WsEventCallback._instance;
|
|
26
|
+
}
|
|
27
|
+
async registerCallback(id, res, rej) {
|
|
28
|
+
let release = await eventMutex.acquire();
|
|
29
|
+
try {
|
|
30
|
+
WsEventCallback._msgActionRegister.set(id, {
|
|
31
|
+
sendTime: new Date().getTime(),
|
|
32
|
+
reject: rej,
|
|
33
|
+
resolve: res,
|
|
34
|
+
timer: setTimeout(() => rej(new wsError_1.WebSocketQueryError(wsError_1.ErrorCode.ERR_WEBSOCKET_QUERY_TIMEOUT, `action:${id.action},req_id:${id.req_id} timeout with ${id.timeout} milliseconds`)), id.timeout)
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
release();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async handleEventCallback(msg, messageType, data) {
|
|
42
|
+
let action = undefined;
|
|
43
|
+
log_1.default.debug("HandleEventCallback msg=", msg, messageType);
|
|
44
|
+
let release = await eventMutex.acquire();
|
|
45
|
+
log_1.default.debug("HandleEventCallback get lock msg=", msg, messageType);
|
|
46
|
+
log_1.default.debug(WsEventCallback._msgActionRegister);
|
|
47
|
+
try {
|
|
48
|
+
for (let [k, v] of WsEventCallback._msgActionRegister) {
|
|
49
|
+
if (messageType == OnMessageType.MESSAGE_TYPE_ARRAYBUFFER) {
|
|
50
|
+
if (k.id == msg.id || k.req_id == msg.id) {
|
|
51
|
+
action = v;
|
|
52
|
+
WsEventCallback._msgActionRegister.delete(k);
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (messageType == OnMessageType.MESSAGE_TYPE_BLOB) {
|
|
57
|
+
if (k.id == msg.id || k.req_id == msg.id) {
|
|
58
|
+
action = v;
|
|
59
|
+
WsEventCallback._msgActionRegister.delete(k);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else if (messageType == OnMessageType.MESSAGE_TYPE_STRING) {
|
|
64
|
+
if (k.req_id == msg.req_id && k.action == msg.action) {
|
|
65
|
+
action = v;
|
|
66
|
+
WsEventCallback._msgActionRegister.delete(k);
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else if (messageType == OnMessageType.MESSAGE_TYPE_CONNECTION) {
|
|
71
|
+
if (k.req_id == msg.req_id && k.action == msg.action) {
|
|
72
|
+
action = v;
|
|
73
|
+
WsEventCallback._msgActionRegister.delete(k);
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
release();
|
|
81
|
+
}
|
|
82
|
+
if (action) {
|
|
83
|
+
let currTime = new Date().getTime();
|
|
84
|
+
let resp = {
|
|
85
|
+
msg: data,
|
|
86
|
+
totalTime: Math.abs(currTime - action.sendTime),
|
|
87
|
+
};
|
|
88
|
+
action.resolve(resp);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
log_1.default.error("no find callback msg:=", msg);
|
|
92
|
+
throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WS_NO_CALLBACK, "no callback registered for fetch_block with req_id=" + msg.req_id + " action" + msg.action);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.WsEventCallback = WsEventCallback;
|
|
97
|
+
WsEventCallback._msgActionRegister = new Map();
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* define ws Response type|class, for query?
|
|
3
|
+
*/
|
|
4
|
+
import { MessageResp } from "../common/taosResult";
|
|
5
|
+
export declare class WSVersionResponse {
|
|
6
|
+
version: string;
|
|
7
|
+
code: number;
|
|
8
|
+
message: string;
|
|
9
|
+
action: string;
|
|
10
|
+
totalTime: number;
|
|
11
|
+
constructor(resp: MessageResp);
|
|
12
|
+
}
|
|
13
|
+
export declare class WSQueryResponse {
|
|
14
|
+
code?: number;
|
|
15
|
+
message?: string;
|
|
16
|
+
action?: string;
|
|
17
|
+
req_id?: number;
|
|
18
|
+
timing?: bigint | null;
|
|
19
|
+
totalTime: number;
|
|
20
|
+
id?: bigint;
|
|
21
|
+
is_update?: boolean;
|
|
22
|
+
affected_rows?: number | null;
|
|
23
|
+
fields_count?: number | null;
|
|
24
|
+
fields_names?: Array<string> | null;
|
|
25
|
+
fields_types?: Array<number> | null;
|
|
26
|
+
fields_lengths?: Array<number> | null;
|
|
27
|
+
precision?: number;
|
|
28
|
+
constructor(resp: MessageResp);
|
|
29
|
+
private initMsg;
|
|
30
|
+
}
|
|
31
|
+
export declare class WSFetchResponse {
|
|
32
|
+
code: number;
|
|
33
|
+
message: string;
|
|
34
|
+
action: string;
|
|
35
|
+
req_id: number;
|
|
36
|
+
timing: bigint;
|
|
37
|
+
id: bigint;
|
|
38
|
+
completed: boolean;
|
|
39
|
+
length: Array<number>;
|
|
40
|
+
rows: number;
|
|
41
|
+
totalTime: number;
|
|
42
|
+
constructor(resp: MessageResp);
|
|
43
|
+
}
|
|
44
|
+
export declare class WSFetchBlockResponse {
|
|
45
|
+
id: bigint;
|
|
46
|
+
data: ArrayBuffer;
|
|
47
|
+
timing: bigint;
|
|
48
|
+
constructor(msg: ArrayBuffer);
|
|
49
|
+
}
|
|
50
|
+
interface IWSConnResponse {
|
|
51
|
+
code: number;
|
|
52
|
+
message: string;
|
|
53
|
+
action: string;
|
|
54
|
+
req_id: number;
|
|
55
|
+
timing: bigint;
|
|
56
|
+
}
|
|
57
|
+
export declare class WSConnResponse {
|
|
58
|
+
code: number;
|
|
59
|
+
message: string;
|
|
60
|
+
action: string;
|
|
61
|
+
req_id: number;
|
|
62
|
+
timing: bigint;
|
|
63
|
+
constructor(msg: IWSConnResponse);
|
|
64
|
+
}
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=wsResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wsResponse.d.ts","sourceRoot":"","sources":["../../../src/client/wsResponse.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,qBAAa,iBAAiB;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;gBACN,IAAI,EAAC,WAAW;CAO/B;AAED,qBAAa,eAAe;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACpC,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACpC,cAAc,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;gBAEP,IAAI,EAAC,WAAW;IAI5B,OAAO,CAAC,OAAO;CAoBlB;AAED,qBAAa,eAAe;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;gBACN,IAAI,EAAC,WAAW;CAY/B;AAED,qBAAa,oBAAoB;IAE7B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,WAAW,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;gBACF,GAAG,EAAE,WAAW;CAK/B;AAED,UAAU,eAAe;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,cAAc;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;gBAEH,GAAG,EAAE,eAAe;CAOnC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* define ws Response type|class, for query?
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.WSConnResponse = exports.WSFetchBlockResponse = exports.WSFetchResponse = exports.WSQueryResponse = exports.WSVersionResponse = void 0;
|
|
7
|
+
class WSVersionResponse {
|
|
8
|
+
constructor(resp) {
|
|
9
|
+
this.version = resp.msg.version;
|
|
10
|
+
this.code = resp.msg.code;
|
|
11
|
+
this.message = resp.msg.message;
|
|
12
|
+
this.action = resp.msg.action;
|
|
13
|
+
this.totalTime = resp.totalTime;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.WSVersionResponse = WSVersionResponse;
|
|
17
|
+
class WSQueryResponse {
|
|
18
|
+
constructor(resp) {
|
|
19
|
+
this.totalTime = resp.totalTime;
|
|
20
|
+
this.initMsg(resp.msg);
|
|
21
|
+
}
|
|
22
|
+
initMsg(msg) {
|
|
23
|
+
this.code = msg.code;
|
|
24
|
+
this.message = msg.message;
|
|
25
|
+
this.action = msg.action;
|
|
26
|
+
this.req_id = msg.req_id;
|
|
27
|
+
this.timing = BigInt(msg.timing);
|
|
28
|
+
if (msg.id) {
|
|
29
|
+
this.id = BigInt(msg.id);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
this.id = BigInt(0);
|
|
33
|
+
}
|
|
34
|
+
this.is_update = msg.is_update;
|
|
35
|
+
this.affected_rows = msg.affected_rows;
|
|
36
|
+
this.fields_count = msg.fields_count;
|
|
37
|
+
this.fields_names = msg.fields_names;
|
|
38
|
+
this.fields_types = msg.fields_types;
|
|
39
|
+
this.fields_lengths = msg.fields_lengths;
|
|
40
|
+
this.precision = msg.precision;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.WSQueryResponse = WSQueryResponse;
|
|
44
|
+
class WSFetchResponse {
|
|
45
|
+
constructor(resp) {
|
|
46
|
+
this.totalTime = resp.totalTime;
|
|
47
|
+
this.code = resp.msg.code;
|
|
48
|
+
this.message = resp.msg.message;
|
|
49
|
+
this.action = resp.msg.action;
|
|
50
|
+
this.req_id = resp.msg.req_id;
|
|
51
|
+
this.timing = BigInt(resp.msg.timing);
|
|
52
|
+
this.id = BigInt(resp.msg.id);
|
|
53
|
+
this.completed = resp.msg.completed;
|
|
54
|
+
this.length = resp.msg.length;
|
|
55
|
+
this.rows = resp.msg.rows;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.WSFetchResponse = WSFetchResponse;
|
|
59
|
+
class WSFetchBlockResponse {
|
|
60
|
+
constructor(msg) {
|
|
61
|
+
this.timing = new DataView(msg, 0, 8).getBigUint64(0, true);
|
|
62
|
+
this.id = new DataView(msg, 8, 8).getBigUint64(0, true);
|
|
63
|
+
this.data = msg.slice(16);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.WSFetchBlockResponse = WSFetchBlockResponse;
|
|
67
|
+
class WSConnResponse {
|
|
68
|
+
constructor(msg) {
|
|
69
|
+
this.code = msg.code;
|
|
70
|
+
this.message = msg.message;
|
|
71
|
+
this.action = msg.action;
|
|
72
|
+
this.req_id = msg.req_id;
|
|
73
|
+
this.timing = BigInt(msg.timing);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.WSConnResponse = WSConnResponse;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare class WSConfig {
|
|
2
|
+
private _user;
|
|
3
|
+
private _password;
|
|
4
|
+
private _db;
|
|
5
|
+
private _url;
|
|
6
|
+
private _timeout;
|
|
7
|
+
private _token;
|
|
8
|
+
constructor(url: string);
|
|
9
|
+
getToken(): string | undefined | null;
|
|
10
|
+
setToken(token: string): void;
|
|
11
|
+
getUser(): string | undefined | null;
|
|
12
|
+
setUser(user: string): void;
|
|
13
|
+
getPwd(): string | undefined | null;
|
|
14
|
+
setPwd(pws: string): void;
|
|
15
|
+
getDb(): string | undefined | null;
|
|
16
|
+
setDb(db: string): void;
|
|
17
|
+
getUrl(): string;
|
|
18
|
+
setUrl(url: string): void;
|
|
19
|
+
setTimeOut(ms: number): void;
|
|
20
|
+
getTimeOut(): number | undefined | null;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/common/config.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACjB,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,GAAG,CAA4B;IACvC,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,QAAQ,CAA0B;IAC1C,OAAO,CAAC,MAAM,CAA2B;gBAE7B,GAAG,EAAC,MAAM;IAIf,QAAQ,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;IAGrC,QAAQ,CAAC,KAAK,EAAE,MAAM;IAItB,OAAO,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;IAGpC,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB,MAAM,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;IAGnC,MAAM,CAAC,GAAG,EAAC,MAAM;IAIjB,KAAK,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;IAGlC,KAAK,CAAC,EAAE,EAAE,MAAM;IAIhB,MAAM,IAAI,MAAM;IAIhB,MAAM,CAAC,GAAG,EAAE,MAAM;IAIlB,UAAU,CAAC,EAAE,EAAG,MAAM;IAGtB,UAAU,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;CAKjD"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WSConfig = void 0;
|
|
4
|
+
class WSConfig {
|
|
5
|
+
constructor(url) {
|
|
6
|
+
this._url = url;
|
|
7
|
+
}
|
|
8
|
+
getToken() {
|
|
9
|
+
return this._token;
|
|
10
|
+
}
|
|
11
|
+
setToken(token) {
|
|
12
|
+
this._token = token;
|
|
13
|
+
}
|
|
14
|
+
getUser() {
|
|
15
|
+
return this._user;
|
|
16
|
+
}
|
|
17
|
+
setUser(user) {
|
|
18
|
+
this._user = user;
|
|
19
|
+
}
|
|
20
|
+
getPwd() {
|
|
21
|
+
return this._password;
|
|
22
|
+
}
|
|
23
|
+
setPwd(pws) {
|
|
24
|
+
this._password = pws;
|
|
25
|
+
}
|
|
26
|
+
getDb() {
|
|
27
|
+
return this._db;
|
|
28
|
+
}
|
|
29
|
+
setDb(db) {
|
|
30
|
+
this._db = db;
|
|
31
|
+
}
|
|
32
|
+
getUrl() {
|
|
33
|
+
return this._url;
|
|
34
|
+
}
|
|
35
|
+
setUrl(url) {
|
|
36
|
+
this._url = url;
|
|
37
|
+
}
|
|
38
|
+
setTimeOut(ms) {
|
|
39
|
+
this._timeout = ms;
|
|
40
|
+
}
|
|
41
|
+
getTimeOut() {
|
|
42
|
+
return this._timeout;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.WSConfig = WSConfig;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface IndexableString {
|
|
2
|
+
[index: number]: string;
|
|
3
|
+
}
|
|
4
|
+
export interface StringIndexable {
|
|
5
|
+
[index: string]: number;
|
|
6
|
+
}
|
|
7
|
+
export declare const TDengineTypeName: IndexableString;
|
|
8
|
+
export declare const ColumnsBlockType: StringIndexable;
|
|
9
|
+
export declare const TDengineTypeCode: StringIndexable;
|
|
10
|
+
export declare const TDenginePrecision: IndexableString;
|
|
11
|
+
export declare const TDengineTypeLength: StringIndexable;
|
|
12
|
+
export declare const PrecisionLength: StringIndexable;
|
|
13
|
+
//# sourceMappingURL=constant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../src/common/constant.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC5B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAC1B;AAED,MAAM,WAAW,eAAe;IAC5B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAC1B;AAED,eAAO,MAAM,gBAAgB,EAAE,eAmB9B,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,eAM9B,CAAA;AAGD,eAAO,MAAM,gBAAgB,EAAE,eAoB9B,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,eAI/B,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,eAahC,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,eAI7B,CAAA"}
|