index.js
function Collector(series, uri) {
    if (!(this instanceof Collector)) {
        return new Collector(series, uri);
    }

    var self = this;

    if (!uri) {
        return;
    }

    if (!series) {
        throw new Error('series name must be specified');
    }

    var parsed = url.parse(uri, true /* parse query args */);

    var username = undefined;
    var password = undefined;

    if (parsed.auth) {
        var parts = parsed.auth.split(':');
        username = parts.shift();
        password = parts.shift();
    }

    self._client = influx({
        host : parsed.hostname,
        port : parsed.port,
        protocol : parsed.protocol,
        username : username,
        password : password,
        database : parsed.pathname.slice(1) // remove leading '/'
    })

    self._points = [];

    var opt = parsed.query || {};

    self._series_name = series;
    self._instant_flush = opt.instantFlush == 'yes';
    self._time_precision = opt.time_precision;

    // no automatic flush
    if (opt.autoFlush == 'no' || self._instant_flush) {
        return;
    }

    var flush_interval = opt.flushInterval || 5000;

    // flush on an interval
    // or option to auto_flush=false
    setInterval(function() {
        self.flush();
    }, flush_interval).unref();
}
function Collector(series, uri) {
    if (!(this instanceof Collector)) {
        return new Collector(series, uri);
    }

    var self = this;

    if (!uri) {
        return;
    }

    if (!series) {
        throw new Error('series name must be specified');
    }

    var parsed = url.parse(uri, true /* parse query args */);

    var username = undefined;
    var password = undefined;

    if (parsed.auth) {
        var parts = parsed.auth.split(':');
        username = parts.shift();
        password = parts.shift();
    }

    self._client = influx({
        host : parsed.hostname,
        port : parsed.port,
        protocol : parsed.protocol,
        username : username,
        password : password,
        database : parsed.pathname.slice(1) // remove leading '/'
    })

    self._points = [];

    var opt = parsed.query || {};

    self._series_name = series;
    self._instant_flush = opt.instantFlush == 'yes';
    self._time_precision = opt.time_precision;

    // no automatic flush
    if (opt.autoFlush == 'no' || self._instant_flush) {
        return;
    }

    var flush_interval = opt.flushInterval || 5000;

    // flush on an interval
    // or option to auto_flush=false
    setInterval(function() {
        self.flush();
    }, flush_interval).unref();
}
function Collector ( series , uri ) { if ( ! ( this instanceof Collector ) ) { return new Collector ( series , uri ) ; } var self = this ; if ( ! uri ) { return ; } if ( ! series ) { throw new Error ( 'series name must be specified' ) ; } var parsed = url . parse ( uri , true /* parse query args */ ) ; var username = undefined ; var password = undefined ; if ( parsed . auth ) { var parts = parsed . auth . split ( ':' ) ; username = parts . shift ( ) ; password = parts . shift ( ) ; } self . _client = influx ( { host : parsed . hostname , port : parsed . port , protocol : parsed . protocol , username : username , password : password , database : parsed . pathname . slice ( 1 ) // remove leading '/' } ) self . _points = [ ] ; var opt = parsed . query || { } ; self . _series_name = series ; self . _instant_flush = opt . instantFlush == 'yes' ; self . _time_precision = opt . time_precision ; // no automatic flush if ( opt . autoFlush == 'no' || self . _instant_flush ) { return ; } var flush_interval = opt . flushInterval || 5000 ; // flush on an interval // or option to auto_flush=false setInterval ( function ( ) { self . flush ( ) ; } , flush_interval ) . unref ( ) ; }
create a collector for the given series
create a collector for the given series