https://github.com/vectorhacker/consul-gateway
A consul connected load balancing http client gateway for microservice applications. Loosely based on Martin Fowlers slides on Testing Strategies in a Microservice Architecture .
https://github.com/vectorhacker/consul-gateway
Last synced: 5 months ago
JSON representation
A consul connected load balancing http client gateway for microservice applications. Loosely based on Martin Fowlers slides on Testing Strategies in a Microservice Architecture .
- Host: GitHub
- URL: https://github.com/vectorhacker/consul-gateway
- Owner: vectorhacker
- Created: 2016-09-01T00:30:13.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-09-04T10:46:18.000Z (almost 10 years ago)
- Last Synced: 2024-04-17T21:43:43.711Z (about 2 years ago)
- Language: JavaScript
- Homepage:
- Size: 8.79 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Consul Gateway
=========
A consul connected load balancing http client gateway for microservice
applications. Loosely based on Martin Fowlers slides on [ Testing Strategies in a Microservice Architecture ](http://martinfowler.com/articles/microservice-testing/).
It uses Consul to get the list of addresses to load balance across and makes
requests using the request-promise library. It can also automatically update
the address list in the background.
Usage:
```javascript
const Gateway = require("consul-gateway");
let gateway = null;
Gateway({ service: "name", version: "1.0" })
.then(_gateway => {
gateway = _gateway;
})
.catch(console.error);
function test() {
gateway.get("/test", { json: false }) // json is true by default
.then(response => {
});
}
```
Methods:
`Gateway({ consul?: object , rpc?: fn() -> promise, name: string, version: string, refreshDelay?: number }) -> Promise`
The version has to be a consul tag that perfectly matches the version string.
`gateway.get(endpoint: string, options: request-promise options) -> Promise`
`gateway.get(endpoint: string, options: request-promise options) -> Promise`
`gateway.put(endpoint: string, body: any, options: request-promise options) -> Promise`
`gateway.post(endpoint: string, body: any, options: request-promise options) -> Promise`