From effc7a6039971c6c13ceea1f2f1e5d64a80c8157 Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Fri, 7 Apr 2023 10:09:10 +0200 Subject: [PATCH] Consul disvocery.go refactoring --- consul/discovery.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/consul/discovery.go b/consul/discovery.go index bc7dac0..722f7f7 100644 --- a/consul/discovery.go +++ b/consul/discovery.go @@ -80,19 +80,17 @@ func (s *Service) Register() error { go func(s *Service) { // startup register ticker := time.NewTicker(time.Millisecond * 100) for range ticker.C { - ok, _ := s.healthCheck() - if ok { + if ok, _ := s.healthCheck(); ok { ticker.Stop() } } }(s) go func(s *Service) { // TTL - interval := s.ttl - time.Second*2 + interval := s.ttl - time.Second*2 // 2 seconds overhead ticker := time.NewTicker(interval) for range ticker.C { - _, err := s.healthCheck() - if err != nil { + if _, err := s.healthCheck(); err != nil { fmt.Printf("TTL Error: %v\n", err) } }