bunyan-influxdb
Advanced tools
Comparing version 0.1.1 to 0.2.1
'use strict'; | ||
var stream = require('stream'); | ||
var util = require('util'); | ||
var stream = require('stream'); | ||
var util = require('util'); | ||
var Writable = stream.Writable; | ||
var influx = require('influx'); | ||
var async = require('async'); | ||
var influx = require('influx'); | ||
var cargo = require('async-timed-cargo'); | ||
var async = require('async'); | ||
@@ -12,3 +13,21 @@ | ||
this.options = options || {}; | ||
this.clientInflux = influx(options.influx); | ||
this.clientInflux = influx(options.influx); | ||
this.cargo = cargo(function (tasks, callback) { | ||
var points = tasks.map(function (t) { | ||
return t.points; | ||
}); | ||
async.retry({ | ||
times: this.options.tries || 1, | ||
interval: this.options.tryInterval || 3000 | ||
}, function (clbk, results) { | ||
this.clientInflux.writePoints(tasks[0].series, points, function (err) { | ||
if (err) { | ||
console.error("Influxdb write error ", err); | ||
} | ||
clbk && clbk(err); | ||
}.bind(this)); | ||
}.bind(this), function (err, result) { | ||
callback(err, result); | ||
}.bind(this)); | ||
}.bind(this), 500, 1000); | ||
} | ||
@@ -20,10 +39,9 @@ | ||
InfluxDBStream.prototype.write = function( chunk ) { | ||
InfluxDBStream.prototype.write = function (chunk) { | ||
chunk = chunk || {}; | ||
if( !this.options.transform ) { | ||
if (!this.options.transform) { | ||
return; | ||
} | ||
var transformed = this.options.transform(chunk); | ||
if( !transformed || transformed.length < 3 ) { | ||
if (!transformed || transformed.length < 3) { | ||
return; | ||
@@ -37,12 +55,9 @@ } | ||
async.retry({times: 3, interval: 3000}, function( clbk, results ){ | ||
//console.log( "Write Point ", series, point, tags, time ); | ||
this.clientInflux.writePoint( series, point, tags, time, function(err) { | ||
if(err) { | ||
console.error( "Influxdb write error ", err ); | ||
} | ||
clbk && clbk( err ); | ||
}.bind(this)); | ||
}.bind(this), function(err, result) { | ||
}.bind(this)); | ||
this.cargo.push({ | ||
series: series, | ||
points: [{value: point, time: time}, tags] | ||
}, function (err) { | ||
//console.log(''); | ||
} | ||
); | ||
@@ -53,7 +68,7 @@ }; | ||
module.exports = function (options) { | ||
if (!options) { | ||
options = {}; | ||
} | ||
return new InfluxDBStream(options); | ||
if (!options) { | ||
options = {}; | ||
} | ||
return new InfluxDBStream(options); | ||
}; | ||
{ | ||
"name": "bunyan-influxdb", | ||
"version": "0.1.1", | ||
"version": "0.2.1", | ||
"description": "Bunyan InfluxDB Stream", | ||
@@ -13,4 +13,5 @@ "main": "index.js", | ||
"async": "^1.5.0", | ||
"async-timed-cargo": "0.0.3", | ||
"influx": "^4.0.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3341
58
3
+ Addedasync-timed-cargo@0.0.3
+ Addedasync-timed-cargo@0.0.3(transitive)