From 176c302f58a387bbb6e728e5b5800d122db00a1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8A=A0=E5=86=B0c?= <379263099@qq.com> Date: Thu, 23 Nov 2023 17:19:36 +0800 Subject: [PATCH] =?UTF-8?q?FIX=20:=20=E6=9C=89=E6=97=B6=E5=AD=98=E5=9C=A8n?= =?UTF-8?q?acos=E5=81=87=E6=B3=A8=E5=86=8C=E7=9A=84=E9=97=AE=E9=A2=98,?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=97=A0=E6=B3=95=E5=8F=91=E7=8E=B0,?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E8=AF=B7=E6=B1=82=E5=BC=82=E5=B8=B8.=20?= =?UTF-8?q?=E7=8E=B0=E5=9C=A8=E4=BF=AE=E6=94=B9=E4=B8=BA=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E5=AE=9E=E4=BE=8B=E5=90=8E=E6=A0=A1=E9=AA=8C=E5=AE=9E=E4=BE=8B?= =?UTF-8?q?=E4=BF=A1=E6=81=AF,=20=E6=B3=A8=E5=86=8C=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E5=88=99=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zrpc/registry/nacos/register.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/zrpc/registry/nacos/register.go b/zrpc/registry/nacos/register.go index e4cd3df..e0d7104 100644 --- a/zrpc/registry/nacos/register.go +++ b/zrpc/registry/nacos/register.go @@ -37,7 +37,7 @@ func RegisterService(opts *Options) error { } // service register - _, err = client.RegisterInstance(vo.RegisterInstanceParam{ + registerStatus, err := client.RegisterInstance(vo.RegisterInstanceParam{ ServiceName: opts.ServiceName, Ip: host, Port: port, @@ -54,6 +54,20 @@ func RegisterService(opts *Options) error { return err } + // check register instance status + if registerStatus == false { + return fmt.Errorf("failed to register instance, status is %v", registerStatus) + } + + // get register info + _, err = client.GetService(vo.GetServiceParam{ + ServiceName: opts.ServiceName, + GroupName: opts.Group, + }) + if err != nil { + return err + } + // service deregister proc.AddShutdownListener(func() { _, err := client.DeregisterInstance(vo.DeregisterInstanceParam{