Consul disvocery.go refactoring
This commit is contained in:
parent
457142d8ad
commit
effc7a6039
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user