-
Notifications
You must be signed in to change notification settings - Fork 44
consul
thiagobustamante edited this page Jul 5, 2017
·
5 revisions
This serviceDiscovery middleware needs to receive an options object containing the following properties.
| Property | Type | Description | Required |
|---|---|---|---|
| serviceName | string | The name of the service to be searched in the service discovery. | true |
| ssl | boolean | True if the connection to service should use SSL (https). | false |
| dc | string | Consul datacenter (defaults to local for agent). | false |
| tag | string | filter by tag. | false |
| loadBalancer |
random or round-robin
|
The Load Balancer strategy used to choose one between the available service nodes. Defaults to random. |
false |
Example:
---
name: TestServiceDiscoveryConsulAPI
version: 1.0.0
path: "/serviceDiscoveryConsul"
proxy:
target:
router:
serviceDiscovery:
name: consul
options:
serviceName: testConsulService
timeout: 5000This configuration will make searches in consul registry for available nodes for the service testConsulService.
You must ensure that you have a serviceDiscovery provider configured for consul.
This consul provider will be used by all API's configurations that use consul as serviceDiscovery middleware.
To configure a consul provider, you must use the consul middleware for serviceDiscovery Provider, on GatewayConfig object:
---
gateway:
serviceDiscovery:
provider:
- name: consul
options:
host: localhost
port: 8500
This serviceDiscovery provider middleware needs to receive an options object containing the following properties.
| Property | Type | Description | Required |
|---|---|---|---|
| host | string | Agent address. Default: 127.0.0.1. It is not recommended to access consul agent remotely. see this. So, we recommend to use the default value. | false |
| port | string | number | Agent HTTP(S) port. Default: 8500. |
| secure | boolean | Enable HTTPS. Default: false. | false |
| ca | string[] | The filenames of trusted certificates in PEM format. | false |
| defaults | DefaultsConsulConfig | Default options for all servicediscovery method calls. | false |
Configure default options for all servicediscovery method calls. Can have the following properties:
| Property | Type | Description | Required |
|---|---|---|---|
| dc | string | Datacenter (defaults to local for agent). | false |
| wan | boolean | Return WAN members instead of LAN members. Default: false. | false |
| consistent | boolean | Require strong consistency. Default: false. | false |
| stale | boolean | Use whatever is available, can be arbitrarily stale. Default: false. | false |
| index | string | Used with ModifyIndex to block and wait for changes. | false |
| wait | string or number | Limit how long to wait for changes (ex: 5 minutes), used with index. You can inform the amount of milisencods, or use a human-interval string. Defaults to '30 seconds'. |
false |
| token | string | ACL token. | false |