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() {
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()
}
}
}()