An open API service indexing awesome lists of open source software.

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 .

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`