From 75f7a75379a1c0c7de1787cca13fb46b0b97d58e Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Wed, 17 Jul 2024 21:18:13 +0200 Subject: [PATCH] Fix: switch between domain or ip address for consul registering --- consul/discovery.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/consul/discovery.go b/consul/discovery.go index a57585d..c9ab2af 100644 --- a/consul/discovery.go +++ b/consul/discovery.go @@ -27,16 +27,20 @@ type Service struct { 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.Name = name - s.Address = hostname + s.Address = addr s.appID = id s.domain = domain s.pathPrefix = pathPrefix s.port = appPort s.ttl = time.Second * 10 + if useDomainOverIp == "true" { // FIXME types... + s.Address = domain + } + client, err := consul.NewClient(newClientConfig(servAddr)) if err != nil { return nil, err