Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 39 lines (33 sloc) 865 Bytes
#!/usr/bin/env node
var argv = require('optimist').argv,
stream = require('stream'),
coux = require('coux').coux;
var url = argv['_'][0],
concurrency = argv['c'],
delay = parseInt(argv['d']) || 0,
array = [];
for (var i=0; i < concurrency; i++) {
array.push(i)
}
function postDoc(n) {
return function(cb) {
console.log(n, 'post')
var doc = {"foo":"bar"};
doc.created = new Date().getTime();
coux.post({url:url, agent:false}, doc, function(err, ok) {
if (!err) {
console.log(n,'ok')
setTimeout(function() {cb();},delay);
} else {
console.log(n,'error', err)
}
})
};
};
array.forEach(function(n) {
var fun = postDoc(n),
funcall = function() {
fun(funcall)
};
fun(funcall);
});