From 67013b90b8f36e0806ab48b828f2cded12c114e1 Mon Sep 17 00:00:00 2001 From: "jianwei.wjw" Date: Wed, 11 Dec 2024 18:37:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B3=A8=E5=86=8C=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/model/nacos.go | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/pkg/model/nacos.go b/pkg/model/nacos.go index ee4071c..cbe9b79 100644 --- a/pkg/model/nacos.go +++ b/pkg/model/nacos.go @@ -122,10 +122,8 @@ func (c *nacosClient) RegisterServiceInstances(serviceInfo ServiceInfo, addresse logger.Warnf("Update service health check type fail, service (%s@@%s) is not registered.", serviceInfo.ServiceName, serviceInfo.Group) return } - - instances := make([]vo.RegisterInstanceParam, 0, len(addresses)) for _, address := range addresses { - instances = append(instances, vo.RegisterInstanceParam{ + if _, err := c.client.RegisterInstance(vo.RegisterInstanceParam{ Ip: address.IP, Port: address.Port, Weight: DefaultNacosEndpointWeight, @@ -135,31 +133,10 @@ func (c *nacosClient) RegisterServiceInstances(serviceInfo ServiceInfo, addresse ServiceName: serviceInfo.ServiceName, GroupName: serviceInfo.Group, Ephemeral: false, - }) - //if _, err := c.client.RegisterInstance(vo.RegisterInstanceParam{ - // Ip: address.IP, - // Port: address.Port, - // Weight: DefaultNacosEndpointWeight, - // Enable: true, - // Healthy: true, - // Metadata: serviceInfo.Metadata, - // ServiceName: serviceInfo.ServiceName, - // GroupName: serviceInfo.Group, - // Ephemeral: false, - //}); err != nil { - // logger.Errorf("Register instance (%s:%d) with service (%s@@%s) fail, err %v.", - // address.IP, address.Port, serviceInfo.ServiceName, serviceInfo.Group, err) - //} - } - - success, err := c.client.BatchRegisterInstance(vo.BatchRegisterInstanceParam{ - ServiceName: serviceInfo.ServiceName, - GroupName: serviceInfo.Group, - Instances: instances, - }) - - if !success || err != nil { - logger.Errorf("Batch register instances with service (%s@@%s) fail, instances: %s, err %v.", serviceInfo.ServiceName, serviceInfo.Group, instances, err) + }); err != nil { + logger.Errorf("Register instance (%s:%d) with service (%s@@%s) fail, err %v.", + address.IP, address.Port, serviceInfo.ServiceName, serviceInfo.Group, err) + } } }