Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/1602/request-scaled
Request wrapper with scaling capabilities (dns lookup, ip address selection)
https://github.com/1602/request-scaled
Last synced: about 1 month ago
JSON representation
Request wrapper with scaling capabilities (dns lookup, ip address selection)
- Host: GitHub
- URL: https://github.com/1602/request-scaled
- Owner: 1602
- License: mit
- Created: 2016-06-11T10:23:13.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-06-12T15:35:04.000Z (over 8 years ago)
- Last Synced: 2024-09-14T00:23:57.449Z (2 months ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Request scaled
The `request-scaled` is a wrapper around `request` to work with scaled services, for example multiple instances of docker container.
## Motivation
Normally if you want to scale you should use load balancer such as nginx or haproxy,
autogenerate config file for your balancer based of infrastructure changes. In other words amount of accidental complexity it requires to add is big enough to not even think of scaling at quick prototyping stage.But what if we could avoid this accidental complexity and only do what is essential for scaling of http server: sending requests to different instances of service.
All we have to do then is to perform dns lookup, pick random ip and use it instead of host, this is exactly and the only thing this library does.
## Usage
```
const request = require('request');
const requestScaled = require('request-scaled')(request);// use requestScaled as you would use request
requestScaled.get('http://api:3000/perform/heavy/query')
.then(res => {
// res is http response
})
.catch(err => {
// handle error
console.error('Error from api:3000/perform/heavy/query', err);
});
```## Control over DNS lookup
no control yet, maybe coming soon
## LICENSE
[MIT](./LICENSE)