node-red-contrib-questdb 0.6.24 → 0.6.26
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/nodes/questdb-value.js +9 -2
- package/nodes/questdb.js +18 -9
- package/package.json +1 -1
package/nodes/questdb-value.js
CHANGED
|
@@ -237,7 +237,11 @@ module.exports = function (RED) {
|
|
|
237
237
|
connection.rowCount = 0;
|
|
238
238
|
} catch (flushErr) {
|
|
239
239
|
var flushErrMsg = formatError(flushErr, { operation: 'flush', table: tableName });
|
|
240
|
-
|
|
240
|
+
var flushNow = Date.now();
|
|
241
|
+
if (flushNow - connection.lastFlushErrorLog > 5000) {
|
|
242
|
+
connection.lastFlushErrorLog = flushNow;
|
|
243
|
+
RED.log.error('[QuestDB] Flush failed: ' + flushErrMsg);
|
|
244
|
+
}
|
|
241
245
|
if (isDisconnectionError(flushErr)) {
|
|
242
246
|
connection.updateState(false, flushErr.message);
|
|
243
247
|
connection.sender = null;
|
|
@@ -269,9 +273,12 @@ module.exports = function (RED) {
|
|
|
269
273
|
}
|
|
270
274
|
});
|
|
271
275
|
|
|
272
|
-
node.on('close', function (done) {
|
|
276
|
+
node.on('close', async function (done) {
|
|
273
277
|
connection.emitter.removeListener('stateChange', stateChangeHandler);
|
|
274
278
|
connection.users--;
|
|
279
|
+
if (connection.users <= 0) {
|
|
280
|
+
await connection.disconnect();
|
|
281
|
+
}
|
|
275
282
|
done();
|
|
276
283
|
});
|
|
277
284
|
}
|
package/nodes/questdb.js
CHANGED
|
@@ -107,6 +107,7 @@ module.exports = function (RED) {
|
|
|
107
107
|
emitter: new EventEmitter(),
|
|
108
108
|
lastError: null,
|
|
109
109
|
lastNotConnectedLog: 0,
|
|
110
|
+
lastFlushErrorLog: 0,
|
|
110
111
|
|
|
111
112
|
// Method to update state and emit event
|
|
112
113
|
updateState: function (newStatus, error = null) {
|
|
@@ -179,7 +180,11 @@ module.exports = function (RED) {
|
|
|
179
180
|
connectionState.rowCount = 0;
|
|
180
181
|
} catch (flushErr) {
|
|
181
182
|
const flushErrMsg = formatError(flushErr, { operation: 'auto-flush' });
|
|
182
|
-
|
|
183
|
+
var now = Date.now();
|
|
184
|
+
if (now - connectionState.lastFlushErrorLog > 5000) {
|
|
185
|
+
connectionState.lastFlushErrorLog = now;
|
|
186
|
+
RED.log.error(`[QuestDB] Flush failed: ${flushErrMsg}`);
|
|
187
|
+
}
|
|
183
188
|
connectionState.emitter.emit('flushError', flushErr);
|
|
184
189
|
if (isDisconnectionError(flushErr)) {
|
|
185
190
|
connectionState.updateState(false, flushErr.message);
|
|
@@ -249,12 +254,9 @@ module.exports = function (RED) {
|
|
|
249
254
|
|
|
250
255
|
configNode.on('close', async function (done) {
|
|
251
256
|
const conn = connectionPool.get(connectionKey);
|
|
252
|
-
if (conn) {
|
|
253
|
-
conn.
|
|
254
|
-
|
|
255
|
-
await conn.disconnect();
|
|
256
|
-
connectionPool.delete(connectionKey);
|
|
257
|
-
}
|
|
257
|
+
if (conn && conn.users <= 0) {
|
|
258
|
+
await conn.disconnect();
|
|
259
|
+
connectionPool.delete(connectionKey);
|
|
258
260
|
}
|
|
259
261
|
done();
|
|
260
262
|
});
|
|
@@ -579,7 +581,11 @@ module.exports = function (RED) {
|
|
|
579
581
|
connection.rowCount = 0;
|
|
580
582
|
} catch (flushErr) {
|
|
581
583
|
const flushErrMsg = formatError(flushErr, { operation: 'flush', table: tableName });
|
|
582
|
-
|
|
584
|
+
var flushNow = Date.now();
|
|
585
|
+
if (flushNow - connection.lastFlushErrorLog > 5000) {
|
|
586
|
+
connection.lastFlushErrorLog = flushNow;
|
|
587
|
+
RED.log.error(`[QuestDB] Flush failed: ${flushErrMsg}`);
|
|
588
|
+
}
|
|
583
589
|
if (isDisconnectionError(flushErr)) {
|
|
584
590
|
connection.updateState(false, flushErr.message);
|
|
585
591
|
connection.sender = null;
|
|
@@ -622,10 +628,13 @@ module.exports = function (RED) {
|
|
|
622
628
|
}
|
|
623
629
|
});
|
|
624
630
|
|
|
625
|
-
node.on('close', function (done) {
|
|
631
|
+
node.on('close', async function (done) {
|
|
626
632
|
// Unsubscribe from state changes
|
|
627
633
|
connection.emitter.removeListener('stateChange', stateChangeHandler);
|
|
628
634
|
connection.users--;
|
|
635
|
+
if (connection.users <= 0) {
|
|
636
|
+
await connection.disconnect();
|
|
637
|
+
}
|
|
629
638
|
done();
|
|
630
639
|
});
|
|
631
640
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-questdb",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.26",
|
|
4
4
|
"description": "Node-RED nodes for writing high-performance time-series data to QuestDB using Influx Line Protocol (ILP). Supports IoT, industrial monitoring, smart buildings, fleet telematics, healthcare, agriculture, and more.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Holger Amort"
|