Skip to content

Commit 63b2284

Browse files
author
semyon-slepov
committed
Make server URL base variable names less ambiguous
1 parent f085b6b commit 63b2284

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

config.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ type eureka struct {
3434
ServerDNSName string // default ""
3535
ServiceUrls []string // default []
3636
ServerPort int // default 7001
37+
ServerURLBase string // default "eureka/v2"
3738
PollIntervalSeconds int // default 30
3839
EnableDelta bool // TODO: Support querying for deltas
3940
PreferSameZone bool // default false
4041
RegisterWithEureka bool // default false
4142
Retries int // default 3
42-
ServerContext string // default "eureka/v2"
4343
}
4444

4545
// ReadConfig from a file location. Minimal error handling. Just bails and passes up
@@ -68,7 +68,7 @@ func (c *Config) fillDefaults() {
6868
if c.Eureka.PollIntervalSeconds == 0 {
6969
c.Eureka.PollIntervalSeconds = 30
7070
}
71-
if c.Eureka.ServerContext == "" {
72-
c.Eureka.ServerContext = "eureka/v2"
71+
if len(c.Eureka.ServerURLBase) == 0 {
72+
c.Eureka.ServerURLBase = "eureka/v2"
7373
}
7474
}

connection.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func (e *EurekaConnection) SelectServiceURL() string {
2020
e.discoveryTtl = make(chan struct{}, 1)
2121
}
2222
if e.DNSDiscovery && len(e.discoveryTtl) == 0 {
23-
servers, ttl, err := discoverDNS(e.DiscoveryZone, e.ServicePort, e.ServerContext)
23+
servers, ttl, err := discoverDNS(e.DiscoveryZone, e.ServicePort, e.ServerURLBase)
2424
if err != nil {
2525
return choice(e.ServiceUrls)
2626
}
@@ -68,7 +68,7 @@ func NewConnFromConfig(conf Config) (c EurekaConnection) {
6868
log.Warning("UseDNSForServiceUrls is an experimental option")
6969
c.DNSDiscovery = true
7070
c.DiscoveryZone = conf.Eureka.DNSDiscoveryZone
71-
c.ServerContext = conf.Eureka.ServerContext
71+
c.ServerURLBase = conf.Eureka.ServerURLBase
7272
}
7373
return c
7474
}

dns_discover.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const azURL = "http://169.254.169.254/latest/meta-data/placement/availability-zo
1414

1515
var ErrNotInAWS = fmt.Errorf("Not in AWS")
1616

17-
func discoverDNS(domain string, port int, context string) (servers []string, ttl time.Duration, err error) {
17+
func discoverDNS(domain string, port int, urlBase string) (servers []string, ttl time.Duration, err error) {
1818
r, _ := region()
1919

2020
// all DNS queries must use the FQDN
@@ -35,7 +35,7 @@ func discoverDNS(domain string, port int, context string) (servers []string, ttl
3535
}
3636
for _, instance := range instances {
3737
// format the service URL
38-
servers = append(servers, fmt.Sprintf("http://%s:%d/%s", instance, port, context))
38+
servers = append(servers, fmt.Sprintf("http://%s:%d/%s", instance, port, urlBase))
3939
}
4040
}
4141
return

struct.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type EurekaConnection struct {
2525
DNSDiscovery bool
2626
DiscoveryZone string
2727
discoveryTtl chan struct{}
28-
ServerContext string
28+
ServerURLBase string
2929
UseJson bool
3030
}
3131

0 commit comments

Comments
 (0)