Skip to content

Commit 0719cfb

Browse files
Fabian Hollerfho
authored andcommitted
document that resolver settings can be defined via consul env vars
The consul client is created via consul.NewClient(). This methods reads settings from environment variables if they are not specified. Document that the resolver can be configured via the consul environment variables.
1 parent af39cb6 commit 0719cfb

2 files changed

Lines changed: 25 additions & 10 deletions

File tree

README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,23 @@ following format:
1919
consul://[<consul-server>]/<serviceName>[?<OPT>[&<OPT>]...]
2020
```
2121

22-
The default for `<consul-server>` is `127.0.0.1:8500`.
23-
2422
`<OPT>` is one of:
2523

26-
| OPT | Format | Default | Description |
27-
|------------|---------------------------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
28-
| scheme | `http\|https` | | Establish connection to consul via http or https. |
29-
| tags | `<tag>,[,<tag>]...` | | Filter service by tags |
30-
| health | `healthy\|fallbackToUnhealthy` | healthy | `healthy` resolves only to services with a passing health status.<br>`fallbackToUnhealthy` resolves to unhealthy ones if none exist with passing healthy status. |
31-
| token | `string` | | Authenticate Consul API Request with the token. |
24+
| OPT | Format | Default | Description |
25+
|------------|---------------------------------|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
26+
| scheme | `http\|https` | default from [github.com/hashicorp/consul/api](https://pkg.go.dev/github.com/hashicorp/consul/api) | Establish connection to consul via http or https. |
27+
| tags | `<tag>,[,<tag>]...` | | Filter service by tags |
28+
| health | `healthy\|fallbackToUnhealthy` | healthy | `healthy` resolves only to services with a passing health status.<br>`fallbackToUnhealthy` resolves to unhealthy ones if none exist with passing healthy status. |
29+
| token | `string` | default from [github.com/hashicorp/consul/api](https://pkg.go.dev/github.com/hashicorp/consul/api) | Authenticate Consul API Request with the token. |
30+
31+
If a setting is not specified in the URI, including `<consul-server>`, the
32+
settings defined via the standard
33+
[Consul Environment Variables](https://developer.hashicorp.com/consul/commands#environment-variables)
34+
are used. If the corresponding environment variable is also not defined, the
35+
defaults of the Consul Client is used. The supported environment variables and
36+
their default values might differ depending on the version of the used
37+
[github.com/hashicorp/consul/api](https://pkg.go.dev/github.com/hashicorp/consul/api)
38+
package.
3239

3340
## Example
3441

consul/builder.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
//
1212
// consul://[<consul-server>]/<serviceName>[?<OPT>[&<OPT>]...]
1313
//
14-
// When consul-server is not specified 127.0.0.1:8500 is used.
15-
//
1614
// OPT is one of:
1715
//
1816
// - scheme=http|https specifies if the connection to Consul is established
@@ -29,7 +27,17 @@
2927
// If an OPT is defined multiple times, only the value of the last occurrence
3028
// is used.
3129
//
30+
// The resolver can also be configured via the standard [Consul Environment Variables].
31+
// The supported environment variables and their defaults depend on the version
32+
// of the [github.com/hashicorp/consul/api] package.
33+
//
34+
// If consul-server, scheme or token is not specified in the URL, the settings
35+
// defined via the [Consul Environment Variables] are used. If they are not
36+
// defined, the defaults of the [github.com/hashicorp/consul/api.NewClient] are
37+
// used.
38+
//
3239
// [Blocking Consul queries]: https://developer.hashicorp.com/consul/api-docs/features/blocking
40+
// [Consul Environment Variables]: https://developer.hashicorp.com/consul/commands#environment-variables
3341
package consul
3442

3543
import (

0 commit comments

Comments
 (0)