Skip to content

Commit

Permalink
Prefer named functions over anonymous functions for more readable
Browse files Browse the repository at this point in the history
backtraces.
  • Loading branch information
mheffner committed Apr 26, 2012
1 parent 80374f3 commit 784f07a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
12 changes: 4 additions & 8 deletions backends/graphite.js
Expand Up @@ -22,7 +22,7 @@ var graphitePort;

var graphiteStats = {};

var post_stats = function(statString) {
var post_stats = function graphite_post_stats(statString) {
if (graphiteHost) {
try {
var graphite = net.createConnection(graphitePort, graphiteHost);
Expand All @@ -45,7 +45,7 @@ var post_stats = function(statString) {
}
}

var flush_stats = function(ts, metrics) {
exports.flush = function graphite_flush(ts, metrics) {
var statString = '';
var numStats = 0;
var key;
Expand Down Expand Up @@ -120,13 +120,13 @@ var flush_stats = function(ts, metrics) {
post_stats(statString);
};

var backend_stats = function(writeCb) {
exports.stats = function graphite_stats(writeCb) {
for (stat in graphiteStats) {
writeCb(null, stat, graphiteStats[stat]);
}
};

var init_backend = function(startup_time, config) {
exports.init = function graphite_init(startup_time, config) {
debug = config.debug;
graphiteHost = config.graphiteHost;
graphitePort = config.graphitePort;
Expand All @@ -138,7 +138,3 @@ var init_backend = function(startup_time, config) {

return true;
};

exports.init = init_backend;
exports.flush = flush_stats;
exports.stats = backend_stats;
4 changes: 2 additions & 2 deletions stats.js
Expand Up @@ -14,7 +14,7 @@ var debugInt, flushInterval, keyFlushInt, server, mgmtServer;
var startup_time = Math.round(new Date().getTime() / 1000);

// Load and init the backend from the backends/ directory.
var loadBackend = function(config, name) {
function loadBackend(config, name) {
var backendmod = require("./backends/" + name);
var backend = {
name: name,
Expand All @@ -35,7 +35,7 @@ var loadBackend = function(config, name) {
};

// Flush metrics to each backend.
var flushMetrics = function() {
function flushMetrics() {
var ts = Math.round(new Date().getTime() / 1000);

var metrics = {
Expand Down

0 comments on commit 784f07a

Please sign in to comment.