From 3afe78f9e3f82ac29ce4ac3e34f65df92f46d01d Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Fri, 19 Jul 2024 17:06:39 +0200 Subject: [PATCH] fix in consul discovery --- consul/discovery.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/consul/discovery.go b/consul/discovery.go index 3645e3e..d5b48c4 100644 --- a/consul/discovery.go +++ b/consul/discovery.go @@ -115,21 +115,20 @@ func (s *Service) Unregister() error { func (s *Service) RegisterHealthChecks() { go func() { // startup register - s.hcTicker = time.NewTicker(time.Second) - for range s.hcTicker.C { + t := time.NewTicker(time.Second) + for range t.C { if ok, _ := s.healthCheck(); ok { - fmt.Println("Stoping HC Ticker goroutine") - s.hcTicker.Stop() + t.Stop() } } }() go func() { // TTL - s.ttlTicker = time.NewTicker(s.ttl) - for range s.ttlTicker.C { + t := time.NewTicker(s.ttl) + for range t.C { if _, err := s.healthCheck(); err != nil { - fmt.Printf("HealthCheck endpoint not available (%s)#: %v\n", s.GetFullAddr(), err) - s.ttlTicker.Stop() + // fmt.Printf("HealthCheck endpoint not available (%s)#: %v\n", s.GetFullAddr(), err) + t.Stop() } } }()