@jambonz/time-series 0.1.8 → 0.1.9
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/index.js +12 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -379,6 +379,7 @@ module.exports = (logger, opts) => {
|
|
|
379
379
|
|
|
380
380
|
const cdrClient = new Influx.InfluxDB({database: 'cdrs', schemas: schemas.cdr, ...opts});
|
|
381
381
|
const alertClient = new Influx.InfluxDB({database: 'alerts', schemas: schemas.alerts, ...opts});
|
|
382
|
+
const callCountClient = new Influx.InfluxDB({database: 'call_counts', schemas: schemas.call_counts, ...opts});
|
|
382
383
|
|
|
383
384
|
cdrClient.locals = {
|
|
384
385
|
db: 'cdrs',
|
|
@@ -396,15 +397,24 @@ module.exports = (logger, opts) => {
|
|
|
396
397
|
commitInterval: opts.commitInterval || 10,
|
|
397
398
|
data: []
|
|
398
399
|
};
|
|
400
|
+
callCountClient.locals = {
|
|
401
|
+
db: 'call_counts',
|
|
402
|
+
initialized: false,
|
|
403
|
+
writing: false,
|
|
404
|
+
commitSize: opts.commitSize || 1,
|
|
405
|
+
commitInterval: opts.commitInterval || 10,
|
|
406
|
+
data: []
|
|
407
|
+
};
|
|
399
408
|
|
|
400
409
|
if (opts.commitSize > 1 && opts.commitInterval && opts.commitInterval > 2) {
|
|
410
|
+
setInterval(writeData.bind(null, callCountClient), opts.commitInterval * 1000);
|
|
401
411
|
setInterval(writeData.bind(null, cdrClient), opts.commitInterval * 1000);
|
|
402
412
|
setInterval(writeData.bind(null, alertClient), opts.commitInterval * 1000);
|
|
403
413
|
}
|
|
404
414
|
|
|
405
415
|
return {
|
|
406
|
-
writeCallCount: writeCallCount.bind(null,
|
|
407
|
-
queryCallCounts: queryCallCounts.bind(null,
|
|
416
|
+
writeCallCount: writeCallCount.bind(null, callCountClient),
|
|
417
|
+
queryCallCounts: queryCallCounts.bind(null, callCountClient),
|
|
408
418
|
writeCdrs: writeCdrs.bind(null, cdrClient),
|
|
409
419
|
queryCdrs: queryCdrs.bind(null, cdrClient),
|
|
410
420
|
writeAlerts: writeAlerts.bind(null, alertClient),
|