-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfig.go
70 lines (64 loc) · 1.81 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package consulresolver
import (
"net/http"
"github.com/hashicorp/consul/api"
)
type LogFn func(format string, args ...interface{})
type ServiceSpec struct {
// The name of the service in Consul.
// Mandatory
ServiceName string
// The port to use, if different from the `Service.Port` in Consul
// If set to a value other than 0, this will override the service port discovered in Consul.
// Optional
// Default: 0
ServicePort int
// Filter service instances by Consul tags.
// Optional
// Default: nil
Tags []string
// Filter service instances by Health status.
// Optional
// Default: false (only healthy endpoints are used)
IncludeUnhealthy bool
}
type TransportConfig struct {
// A function that will be used for logging.
// Optional
// Default: log.Printf
Log LogFn
// The resolvers to be used for address resolution.
// Multiple resolvers are supported, and will be looked up by the `ServiceName`
// Mandatory
Resolvers []Resolver
// If true, the transport will fallback to net/Resolver on resolver error
// Optional
// Default: false
NetResolverFallback bool
// A base transport to be used for the underlying request handling.
// Optional
// Default: http.DefaultTransport
Base http.RoundTripper
}
type ResolverConfig struct {
// A function that will be used for logging.
// Optional
// Default: log.Printf
Log LogFn
// The Service Spec the resolver will handle
// Mandatory
ServiceSpec ServiceSpec
// The Balancer that will be used to select targets
// Optional
// Default: RoundRobinLoadBalancer
Balancer Balancer
// The consul client
// Mandatory
Client *api.Client
// The consul query options configuration
// Optional
Query *api.QueryOptions
// A list of datacenters to query, ordered by priority.
// Optional. Will use only the local DC if not provided.
FallbackDatacenters []string
}