request-worker
v1.1.0
Published
Module that utilizes worker processes to perform HTTP requests.
Downloads
7
Readme
request-worker
Module that utilizes worker processes to perform HTTP requests. Useful if you need to make a large number of HTTP requests or the requests you're making will take a long time to get a response. request-worker uses the request module to perform the request; all the same options are supported.
Installation
This package is available on npm as:
npm install request-worker
Usage
A singleton is available if you want to share workers:
RequestWorker.getInstance({count: 16})
.request({
method : 'GET',
url : 'http://google.com/'
})
.then(function (results) {
if (results.response.statusCode === 200) {
var data = JSON.parse(results.body);
// implementation...
} else {
// stuff...
}
})
.fail(function (error) {
// error handling...
})
.done();
You can also create your own instance:
var requestWorker = new RequestWorker({count: 16});
requestWorker
.request(...)
.then(...)
.fail(...)
.done();
License
MIT