Launch Week Day 2: Introducing Reports: An Extensible Reporting Framework for Socket Data.Learn More
Socket
Book a DemoSign in
Socket

cube

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cube - npm Package Compare versions

Comparing version
0.2.1
to
0.2.2
+49
lib/cube/emitter-http.js
var util = require("util"),
http = require("http");
module.exports = function(protocol, host, port) {
var emitter = {},
queue = [],
closing;
if (protocol != "http:") throw new Error("invalid HTTP protocol");
function send() {
var events = queue.splice(0, 500),
body = JSON.stringify(events);
http.request({
host: host,
port: port,
path: "/1.0/event",
method: "POST",
headers: {
"Content-Type": "application/json",
"Content-Length": body.length
}
}, function(response) {
if (response.statusCode !== 200) return error(response.statusCode);
if (queue.length) setTimeout(send, 500);
}).on("error", function(e) {
error(e.message);
}).end(body);
function error(message) {
util.log("error: " + message);
queue.unshift.apply(queue, events);
setTimeout(send, 1000);
}
}
emitter.send = function(event) {
if (!closing && queue.push(event) === 1) setTimeout(send, 500);
return emitter;
};
emitter.close = function () {
if (queue.length) closing = 1;
return emitter;
};
return emitter;
};
+2
-0
var util = require("util"),
url = require("url"),
http = require("./emitter-http"),
udp = require("./emitter-udp"),

@@ -12,4 +13,5 @@ ws = require("./emitter-ws");

case "ws:": case "wss:": emitter = ws; break;
case "http:": emitter = http; break;
}
return emitter(u.protocol, u.hostname, u.port);
};
+2
-1

@@ -109,3 +109,4 @@ // TODO include the event._id (and define a JSON encoding for ObjectId?)

i = bisect(tierTimes, tierTime);
if (tierTimes[i] > tierTime) tierTimes.splice(i, 0, tierTime);
if (i >= tierTimes.length) tierTimes.push(tierTime);
else if (tierTimes[i] > tierTime) tierTimes.splice(i, 0, tierTime);
}

@@ -112,0 +113,0 @@ } else {

@@ -134,5 +134,5 @@ var util = require("util"),

file.serve(request, response, function(error) {
if (error && error.status == 404) {
response.writeHead(404, {"Content-Type": "text/plain"});
response.end("404 Not Found");
if (error) {
response.writeHead(error.status, {"Content-Type": "text/plain"});
response.end(error.status + "");
}

@@ -139,0 +139,0 @@ });

{
"name": "cube",
"version": "0.2.1",
"version": "0.2.2",
"description": "A system for analyzing time series data using MongoDB and Node.",

@@ -11,3 +11,3 @@ "keywords": ["time series"],

"dependencies": {
"mongodb": "0.9.9-8",
"mongodb": "1.0.1",
"node-static": "0.5.9",

@@ -14,0 +14,0 @@ "pegjs": "0.6.2",