fix in consul discovery

This commit is contained in:
Piotr Biernat 2024-07-19 17:06:39 +02:00
parent eb763ed49c
commit 3afe78f9e3

View File

@ -115,21 +115,20 @@ func (s *Service) Unregister() error {
func (s *Service) RegisterHealthChecks() { func (s *Service) RegisterHealthChecks() {
go func() { // startup register go func() { // startup register
s.hcTicker = time.NewTicker(time.Second) t := time.NewTicker(time.Second)
for range s.hcTicker.C { for range t.C {
if ok, _ := s.healthCheck(); ok { if ok, _ := s.healthCheck(); ok {
fmt.Println("Stoping HC Ticker goroutine") t.Stop()
s.hcTicker.Stop()
} }
} }
}() }()
go func() { // TTL go func() { // TTL
s.ttlTicker = time.NewTicker(s.ttl) t := time.NewTicker(s.ttl)
for range s.ttlTicker.C { for range t.C {
if _, err := s.healthCheck(); err != nil { if _, err := s.healthCheck(); err != nil {
fmt.Printf("HealthCheck endpoint not available (%s)#: %v\n", s.GetFullAddr(), err) // fmt.Printf("HealthCheck endpoint not available (%s)#: %v\n", s.GetFullAddr(), err)
s.ttlTicker.Stop() t.Stop()
} }
} }
}() }()