register fix 2
This commit is contained in:
parent
98d85810f3
commit
016bddb5c4
@ -92,16 +92,23 @@ func (s *Service) Register() error {
|
||||
return err
|
||||
}
|
||||
|
||||
go func(s *Service) { // startup register
|
||||
return nil
|
||||
}
|
||||
func (s *Service) Unregister() error {
|
||||
return s.agent.ServiceDeregister(s.GetID())
|
||||
}
|
||||
|
||||
func (s *Service) InitTTL() {
|
||||
go func() { // startup register
|
||||
ticker := time.NewTicker(time.Second * 1)
|
||||
for range ticker.C {
|
||||
if ok, _ := s.healthCheck(); ok {
|
||||
ticker.Stop()
|
||||
}
|
||||
}
|
||||
}(s)
|
||||
}()
|
||||
|
||||
go func(s *Service) { // TTL
|
||||
go func() { // TTL
|
||||
interval := s.ttl - time.Second*2 // 2 seconds overhead
|
||||
ticker := time.NewTicker(interval)
|
||||
for range ticker.C {
|
||||
@ -109,12 +116,7 @@ func (s *Service) Register() error {
|
||||
fmt.Printf("TTL Error #: %v\n", err)
|
||||
}
|
||||
}
|
||||
}(s)
|
||||
|
||||
return nil
|
||||
}
|
||||
func (s *Service) Unregister() error {
|
||||
return s.agent.ServiceDeregister(s.GetID())
|
||||
}()
|
||||
}
|
||||
|
||||
func (s *Service) Connect() (*connect.Service, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user