forked from HikoQiu/go-eureka-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_from_dns.go
34 lines (28 loc) · 922 Bytes
/
client_from_dns.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
package main
import (
"github.com/HikoQiu/go-eureka-client/eureka"
)
func main() {
config := eureka.GetDefaultEurekaClientConfig()
config.UseDnsForFetchingServiceUrls = true
config.Region = "region-cn-hd-1"
config.AvailabilityZones = map[string]string{
"region-cn-hd-1": "zone-cn-hz-1",
}
config.EurekaServerDNSName = "dev.ms-registry.xf.io"
config.EurekaServerUrlContext = "eureka"
config.EurekaServerPort = "9001"
// custom logger
//eureka.SetLogger(func(level int, format string, a ...interface{}) {
// if level == eureka.LevelError {
// fmt.Println("[custom logger error] " + format, a)
// }else {
// fmt.Println("[custom logger debug] " + format, a)
// }
//})
// run eureka client async
eureka.DefaultClient.Config(config).
Register("APP_ID_CLIENT_FROM_DNS", 9000).
Run()
select {}
}