Created
September 30, 2011 05:01
-
-
Save gjohnson/1252714 to your computer and use it in GitHub Desktop.
understanding cluster plugins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var utils = require('cluster/lib/utils') | |
, store = {}; | |
module.exports = function (options) { | |
options = options || {}; | |
ratelimit.enableInWorker = true; | |
function ratelimit (master) { | |
var server = master.server; | |
utils.unshiftListener(server, 'connection', function (sock) { | |
sock.pause(); | |
setTimeout(function(){ | |
sock.resume(); | |
}, 25); | |
}); | |
} | |
return ratelimit; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment