| 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; | ||
| }; |
| 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); | ||
| }; |
@@ -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 @@ }); |
+2
-2
| { | ||
| "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", |
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
739767
0.17%49
2.08%18556
0.24%6
20%+ Added
+ Added
- Removed
- Removed
Updated