pull/2318/head
skiffer-git 6 months ago
parent a08d0d7218
commit 02cc4a2097

@ -95,8 +95,26 @@ func (r *SvcDiscoveryRegistryImpl) Register(serviceName, host string, port int,
return err return err
} }
_, kaErr := r.client.KeepAlive(context.Background(), r.leaseID) go r.keepAliveLease(r.leaseID)
return kaErr
return nil
}
func (r *SvcDiscoveryRegistryImpl) keepAliveLease(leaseID clientv3.LeaseID) {
ch, err := r.client.KeepAlive(context.Background(), leaseID)
if err != nil {
log.Printf("Failed to keep lease alive: %v", err)
return
}
for ka := range ch {
if ka != nil {
fmt.Printf("Received lease keep-alive response: %v", ka)
} else {
fmt.Printf("Lease keep-alive response channel closed")
break
}
}
} }
func (r *SvcDiscoveryRegistryImpl) UnRegister() error { func (r *SvcDiscoveryRegistryImpl) UnRegister() error {

Loading…
Cancel
Save