services/stats.js
function collectStats(callback) {
    var serviceStats = {};
    var services = loader.listServices();
    async.each(services, function(service, callback) {
        var mod = loader.get(service);
        if (mod.stats) { //does it have a stats function?
            invokeStatsOnMod(mod, function(err, data) {
                serviceStats[service] = data;
                return callback(err);
            });
        } else {
            return callback(); //nothing to do, no stats method exposed
        }

    }, function(err) {
        callback(err, serviceStats);
    });

}
function collectStats(callback) {
    var serviceStats = {};
    var services = loader.listServices();
    async.each(services, function(service, callback) {
        var mod = loader.get(service);
        if (mod.stats) { //does it have a stats function?
            invokeStatsOnMod(mod, function(err, data) {
                serviceStats[service] = data;
                return callback(err);
            });
        } else {
            return callback(); //nothing to do, no stats method exposed
        }

    }, function(err) {
        callback(err, serviceStats);
    });

}
function collectStats ( callback ) { var serviceStats = { } ; var services = loader . listServices ( ) ; async . each ( services , function ( service , callback ) { var mod = loader . get ( service ) ; if ( mod . stats ) { //does it have a stats function? invokeStatsOnMod ( mod , function ( err , data ) { serviceStats [ service ] = data ; return callback ( err ) ; } ) ; } else { return callback ( ) ; //nothing to do, no stats method exposed } } , function ( err ) { callback ( err , serviceStats ) ; } ) ; }
Query all the services and invoke the stats method if it exists
Query all the services and invoke the stats method if it exists