Created
June 14, 2015 15:51
-
-
Save nrshrivatsan/8c997511b5d337f9d929 to your computer and use it in GitHub Desktop.
ETCD load script in nodejs
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 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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please do
npm install request