Skip to content

Commit

Permalink
Fix JSHint warnings
Browse files Browse the repository at this point in the history
Fix JSHint warnings
  • Loading branch information
volans- authored and Patrick Koch committed Mar 18, 2016
1 parent dd0b7ee commit 102bf5e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ function is_valid_packet(fields) {
return true;
}

};
}

exports.is_valid_packet = is_valid_packet;
19 changes: 12 additions & 7 deletions proxy.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/*jshint node:true, laxcomma:true */

var dgram = require('dgram')
, net = require('net')
, events = require('events')
Expand Down Expand Up @@ -26,7 +28,7 @@ configlib.configFile(process.argv[2], function (conf, oldConfig) {
var logPrefix = "[" + process.pid + "] ";
var log = function(msg, type) {
l.log(logPrefix + msg, type);
}
};


if (forkCount > 1 && cluster.isMaster) {
Expand Down Expand Up @@ -68,15 +70,18 @@ configlib.configFile(process.argv[2], function (conf, oldConfig) {
var server = servermod.start(config, function (msg, rinfo) {
// Convert the raw packet to a string (defaults to UTF8 encoding)
var packet_data = msg.toString();
var current_metric
, bits
, key;
// If the packet contains a \n then it contains multiple metrics
if (packet_data.indexOf("\n") > -1) {
var metrics;
metrics = packet_data.split("\n");
// Loop through the metrics and split on : to get mertric name for hashing
for (var midx in metrics) {
var current_metric = metrics[midx];
var bits = current_metric.split(':');
var key = bits.shift();
current_metric = metrics[midx];
bits = current_metric.split(':');
key = bits.shift();
if (current_metric !== '') {
var new_msg = new Buffer(current_metric);
packet.emit('send', key, new_msg);
Expand All @@ -85,9 +90,9 @@ configlib.configFile(process.argv[2], function (conf, oldConfig) {

} else {
// metrics needs to be an array to fake it for single metric packets
var current_metric = packet_data;
var bits = current_metric.split(':');
var key = bits.shift();
current_metric = packet_data;
bits = current_metric.split(':');
key = bits.shift();
if (current_metric !== '') {
packet.emit('send', key, msg);
}
Expand Down
19 changes: 10 additions & 9 deletions stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,12 @@ config.configFile(process.argv[2], function (config) {
var handlePacket = function (msg, rinfo) {
backendEvents.emit('packet', msg, rinfo);
counters[packets_received]++;
var metrics;
var packet_data = msg.toString();
if (packet_data.indexOf("\n") > -1) {
var metrics = packet_data.split("\n");
metrics = packet_data.split("\n");
} else {
var metrics = [ packet_data ] ;
metrics = [ packet_data ] ;
}

for (var midx in metrics) {
Expand Down Expand Up @@ -278,16 +279,16 @@ config.configFile(process.argv[2], function (config) {
}

stats.messages.last_msg_seen = Math.round(new Date().getTime() / 1000);
}
};

// If config.servers isn't specified, use the top-level config for backwards-compatibility
var server_config = config.servers || [config]
var server_config = config.servers || [config];
for (var i = 0; i < server_config.length; i++) {
// The default server is UDP
var server = server_config[i].server || './servers/udp'
startServer(server_config[i], server, handlePacket)
var server = server_config[i].server || './servers/udp';
startServer(server_config[i], server, handlePacket);
}
serversLoaded = true
serversLoaded = true;

mgmtServer = net.createServer(function(stream) {
stream.setEncoding('ascii');
Expand Down Expand Up @@ -431,8 +432,8 @@ config.configFile(process.argv[2], function (config) {
config.flushInterval = flushInterval;

if (config.backends) {
for (var i = 0; i < config.backends.length; i++) {
loadBackend(config, config.backends[i]);
for (var j = 0; j < config.backends.length; j++) {
loadBackend(config, config.backends[j]);
}
} else {
// The default backend is graphite
Expand Down

0 comments on commit 102bf5e

Please sign in to comment.