From a08d0d7218f59c57d838296be62e55f7bf4ebd7c Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Sat, 11 May 2024 11:22:49 +0800 Subject: [PATCH] add etcd --- pkg/common/discoveryregister/etcd/etcd.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/pkg/common/discoveryregister/etcd/etcd.go b/pkg/common/discoveryregister/etcd/etcd.go index 04bd57ca5..e627dfedb 100644 --- a/pkg/common/discoveryregister/etcd/etcd.go +++ b/pkg/common/discoveryregister/etcd/etcd.go @@ -91,17 +91,12 @@ func (r *SvcDiscoveryRegistryImpl) Register(serviceName, host string, port int, endpoint := endpoints.Endpoint{Addr: fmt.Sprintf("%s:%d", host, port)} err = em.AddEndpoint(context.TODO(), r.serviceKey, endpoint, clientv3.WithLease(leaseResp.ID)) - return err - // - //lease, _ := r.client.Grant(context.TODO(), 30) - // - //em, err = endpoints.NewManager(r.client, "foo/bar/my-service") - //if err != nil { - // return err - //} - // - //err := em.AddEndpoint(context.TODO(), "foo/bar/my-service/e1", endpoints.Endpoint{Addr: "1.2.3.4"}, clientv3.WithLease(lease.ID)) + if err != nil { + return err + } + _, kaErr := r.client.KeepAlive(context.Background(), r.leaseID) + return kaErr } func (r *SvcDiscoveryRegistryImpl) UnRegister() error {