From 35ca6c6a24dad9482cca1714acd1716a479d9d1a Mon Sep 17 00:00:00 2001 From: barslev Date: Wed, 18 Mar 2020 14:24:27 +0100 Subject: [PATCH 1/2] Updates async to version 3. --- appstats.js | 19 +++++++++++++++---- package.json | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/appstats.js b/appstats.js index 139a9b8..a2cc067 100644 --- a/appstats.js +++ b/appstats.js @@ -9,7 +9,6 @@ */ const async = require('async'); -const util = require('util'); const moment = require('moment'); const parse = require('parse-key-value'); const azureStorage = require('azure-storage'); @@ -285,16 +284,28 @@ class AzureCollectionStats { queueService.getQueueMetadata(queueName, function(error, metadata) { if (!error) { var processed = 0; - async.doWhilst(function(callback) { + async.doWhilst( + function(callback) { stats._getStatsBatch(function(error, aggrStatsBatch) { resultError = error ? error + resultError : resultError; resultStats.add(aggrStatsBatch); processed += STAT_MSG_NUMBER_PER_BATCH; return callback(); }); - }, function() { + }, + function() { + const cb = arguments[arguments.length - 1]; + const args = Array.prototype.slice.call(arguments, 0, arguments.length - 1); + const f = function() { return processed < metadata.approximateMessageCount; - }, function() { + }; + try { + cb(null, f.apply(this, args)); + } catch (e) { + cb(e, null); + } + }, + function() { if (!resultError) { return callback(null, resultStats); } else { diff --git a/package.json b/package.json index c0dacef..8b1210b 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ }, "dependencies": { "al-collector-js": "git://github.com/alertlogic/al-collector-js#master", - "async": "^2.6.1", + "async": "^3.0.0", "azure": "^2.3.1-preview", "parse-key-value": "^1.0.0", "path": "^0.12.7" From 30a4c5743bc0f4f36d1941a69d0cc8062840a911 Mon Sep 17 00:00:00 2001 From: barslev Date: Wed, 18 Mar 2020 14:28:56 +0100 Subject: [PATCH 2/2] Code cleanup --- appstats.js | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/appstats.js b/appstats.js index a2cc067..e50b642 100644 --- a/appstats.js +++ b/appstats.js @@ -284,28 +284,25 @@ class AzureCollectionStats { queueService.getQueueMetadata(queueName, function(error, metadata) { if (!error) { var processed = 0; - async.doWhilst( - function(callback) { + async.doWhilst(function(callback) { stats._getStatsBatch(function(error, aggrStatsBatch) { resultError = error ? error + resultError : resultError; resultStats.add(aggrStatsBatch); processed += STAT_MSG_NUMBER_PER_BATCH; return callback(); }); - }, - function() { - const cb = arguments[arguments.length - 1]; - const args = Array.prototype.slice.call(arguments, 0, arguments.length - 1); - const f = function() { - return processed < metadata.approximateMessageCount; - }; - try { - cb(null, f.apply(this, args)); - } catch (e) { - cb(e, null); - } - }, - function() { + }, function() { + const cb = arguments[arguments.length - 1]; + const args = Array.prototype.slice.call(arguments, 0, arguments.length - 1); + const f = function() { + return processed < metadata.approximateMessageCount; + }; + try { + cb(null, f.apply(this, args)); + } catch (e) { + cb(e, null); + } + }, function() { if (!resultError) { return callback(null, resultStats); } else {