gitee.com/h79/goutils@v1.22.10/discovery/config/config.go (about) 1 package config 2 3 import ( 4 "gitee.com/h79/goutils/common/server" 5 "gitee.com/h79/goutils/discovery/resolver/builder" 6 "net" 7 ) 8 9 type Service struct { 10 // The node name that the endpoint belongs to. 11 Node Node `json:"node"` 12 13 // The network address at which the service can be reached. 14 Server server.Address `json:"server"` 15 16 // The list of tags associated with the service. 17 Tags []string `json:"tags"` 18 19 // The set of metadata associated with the node on which the service is 20 // running. 21 Meta map[string]string `json:"meta"` 22 } 23 24 func (s *Service) Adjust(addr net.Addr, pubIp string) { 25 s.Server = server.ParseV2(addr, pubIp) 26 } 27 28 type Config struct { 29 Service 30 Check server.Health 31 } 32 33 func WithTarget(target builder.Target, health server.Health) Config { 34 return Config{ 35 Service: Service{ 36 Node: Node{ 37 Target: target, 38 }, 39 }, 40 Check: health, 41 } 42 }