From f596a99ee6468ed631e8765f49d8683094284209 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Thu, 9 Dec 2021 17:13:34 +0100 Subject: [PATCH] Implement converter-stream point -> lineProtocol --- .../InfluxPointToLineProtoStream.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/streamHandler/InfluxPointToLineProtoStream.js diff --git a/src/streamHandler/InfluxPointToLineProtoStream.js b/src/streamHandler/InfluxPointToLineProtoStream.js new file mode 100644 index 0000000..a8fc40b --- /dev/null +++ b/src/streamHandler/InfluxPointToLineProtoStream.js @@ -0,0 +1,22 @@ +const logger = require.main.require("./helper/logger.js")("InfluxPointToLineProtoStream"); +const { Transform } = require("stream"); + +/** + * Get points and converts them to Line-protocol + */ +class InfluxPointToLineProtoStream extends Transform{ + constructor(){ + super({ + writableObjectMode: true + }); + } + + _transform(point, encoding, next){ + next(null, point.toLineProtocol() +"\n"); + } +} + +// Specify exports +module.exports = { + InfluxPointToLineProtoStream +}; \ No newline at end of file