From ad4368cdf8c5085f2c7763573b230c3ac64a375d Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Thu, 1 Dec 2022 22:55:42 +0100 Subject: [PATCH] register fix --- consul/discovery.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/consul/discovery.go b/consul/discovery.go index f014778..7a4160a 100644 --- a/consul/discovery.go +++ b/consul/discovery.go @@ -36,6 +36,11 @@ func NewService(serverAddr, appID, appName, ip, domain string, appPort int) (*Se if err != nil { return nil, err } + kv := client.KV() + obj := new(consul.KVPair) + obj.Key = "traefik/http/services/" + s.Name + "/loadBalancer/servers/0/url" + obj.Value = []byte(s.GetFullAddr()) + kv.Put(obj, nil) s.ConsulAgent = client.Agent() return s, nil @@ -72,6 +77,7 @@ func (s *Service) Register() error { if err := s.ConsulAgent.ServiceRegister(def); err != nil { return err } + // s.ConsulAgent. go s.UpdateTTL(def) return nil @@ -120,8 +126,11 @@ func (s *Service) check() (bool, error) { func (s *Service) getMetadata() map[string]string { m := map[string]string{} - key := fmt.Sprintf(`traefik/http/services/%s/loadBalancer/servers/0/url`, s.Name) - m[key] = s.GetFullAddr() + m[`traefik_dwa`] = "a" + + // key := "traefik%2Ftest" + // key := "traefik/http/services/" + s.Name + "/loadBalancer/servers/0/url" + // m[key] = s.GetFullAddr() fmt.Printf("netadata: %v", m)