...
|
...
|
@@ -10,24 +10,12 @@ class Message { |
|
|
}
|
|
|
}
|
|
|
|
|
|
const opt = {
|
|
|
decodeURIComponent: function(str) {
|
|
|
let result = decodeURIComponent(str);
|
|
|
|
|
|
if (result[0] === '"') {
|
|
|
result = String(result);
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
function parseMessage(line) {
|
|
|
let measurement = line.split(',', 1)[0];
|
|
|
let body = line.substring(measurement.length + 1);
|
|
|
let tokens = body.split(' ');
|
|
|
|
|
|
let [tags, fields, time] = [qs.parse(tokens[0], ',', '=', opt), qs.parse(tokens[1], ',', '=', opt), tokens[2]];
|
|
|
let [tags, fields, time] = [qs.parse(tokens[0], ',', '='), qs.parse(tokens[1], ',', '='), tokens[2]];
|
|
|
|
|
|
if (tags.path) {
|
|
|
let [, p] = tags.path.split(']');
|
...
|
...
|
@@ -37,6 +25,10 @@ function parseMessage(line) { |
|
|
tags.route = tags.path;
|
|
|
}
|
|
|
|
|
|
if (!tags.route) {
|
|
|
tags.route = 'null';
|
|
|
}
|
|
|
|
|
|
return new Message(measurement, tags, fields, time);
|
|
|
}
|
|
|
|
...
|
...
|
|