Skip to content

Instantly share code, notes, and snippets.

@nrshrivatsan
Created June 14, 2015 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nrshrivatsan/8c997511b5d337f9d929 to your computer and use it in GitHub Desktop.
Save nrshrivatsan/8c997511b5d337f9d929 to your computer and use it in GitHub Desktop.
ETCD load script in nodejs
var request = require('request');
for(var i = 0; i <= 5000; i++) {
setTimeout(
function(){
request.post(
'http://127.0.0.1:2379/v2/keys/k'+i,
{ form: { value: 'load' } },
function (error, response, body) {
if (!error
&& response.statusCode == 201
/* NOTE 201 is used because ETCD respose gives 201 HTTP status code */
/* Please refer http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.2 */
) {
console.log(body)
}
}
);
},
0);
}
@nrshrivatsan
Copy link
Author

Please donpm install request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment