Fix: switch between domain or ip address for consul registering

This commit is contained in:
Piotr Biernat 2024-07-17 21:18:13 +02:00
parent 398d7a2074
commit 75f7a75379

View File

@ -27,16 +27,20 @@ type Service struct {
var ErrServiceUnavailable = fmt.Errorf("Service is unavailable") var ErrServiceUnavailable = fmt.Errorf("Service is unavailable")
func NewService(servAddr, id, name, hostname, domain, pathPrefix string, appPort int) (*Service, error) { func NewService(servAddr, id, name, useDomainOverIp, addr, domain, pathPrefix string, appPort int) (*Service, error) {
s := new(Service) s := new(Service)
s.Name = name s.Name = name
s.Address = hostname s.Address = addr
s.appID = id s.appID = id
s.domain = domain s.domain = domain
s.pathPrefix = pathPrefix s.pathPrefix = pathPrefix
s.port = appPort s.port = appPort
s.ttl = time.Second * 10 s.ttl = time.Second * 10
if useDomainOverIp == "true" { // FIXME types...
s.Address = domain
}
client, err := consul.NewClient(newClientConfig(servAddr)) client, err := consul.NewClient(newClientConfig(servAddr))
if err != nil { if err != nil {
return nil, err return nil, err