@tdengine/websocket
Version:
The websocket Node.js connector for TDengine. TDengine versions 3.3.2.0 and above are recommended to use this connector.
72 lines (71 loc) • 2.51 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TmqConfig = void 0;
const constant_1 = require("./constant");
class TmqConfig {
constructor(wsConfig) {
// req_id: number;
this.url = null;
this.sql_url = null;
this.user = null;
this.password = null;
this.group_id = null;
this.client_id = null;
this.offset_rest = null;
this.auto_commit = true;
this.auto_commit_interval_ms = 5 * 1000;
this.timeout = 5000;
this.otherConfigs = new Map();
for (const [key, value] of wsConfig) {
switch (key) {
case constant_1.TMQConstants.WS_URL:
this.url = new URL(value);
break;
case constant_1.TMQConstants.CONNECT_USER:
this.user = value;
break;
case constant_1.TMQConstants.CONNECT_PASS:
this.password = value;
break;
case constant_1.TMQConstants.GROUP_ID:
this.group_id = value;
break;
case constant_1.TMQConstants.CLIENT_ID:
this.client_id = value;
break;
case constant_1.TMQConstants.AUTO_OFFSET_RESET:
this.offset_rest = value;
break;
case constant_1.TMQConstants.ENABLE_AUTO_COMMIT:
this.auto_commit = value;
break;
case constant_1.TMQConstants.AUTO_COMMIT_INTERVAL_MS:
this.auto_commit_interval_ms = value;
break;
case constant_1.TMQConstants.CONNECT_MESSAGE_TIMEOUT:
this.timeout = value;
break;
default:
this.otherConfigs.set(key, value);
}
}
if (this.url) {
if (this.user) {
this.url.username = this.user;
}
else {
this.user = this.url.username;
}
if (this.password) {
this.url.password = this.password;
}
else {
this.password = this.url.password;
}
this.sql_url = new URL(this.url);
this.sql_url.pathname = '/ws';
this.url.pathname = '/rest/tmq';
}
}
}
exports.TmqConfig = TmqConfig;