From 98c0648038e3514839ab2b498f2fdea306641aab Mon Sep 17 00:00:00 2001 From: whalecold Date: Wed, 1 Nov 2023 14:36:19 +0800 Subject: [PATCH] ignore the GetConfig error and add comments --- nacos/nacos.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nacos/nacos.go b/nacos/nacos.go index 29cbb20..d9b5e7d 100644 --- a/nacos/nacos.go +++ b/nacos/nacos.go @@ -251,6 +251,7 @@ func (c *client) listenConfig(param vo.ConfigParam, uniqueID int64) { Type: param.Type, OnChange: c.onChange, }) + // Performs only local connection and fails only when the input params are invalid if err != nil { panic(err) } @@ -267,10 +268,12 @@ func (c *client) RegisterConfigCallback(param vo.ConfigParam, callback(data, c.parser) } + // NOTE: does not ensure that GetConfig succeeds, the govern policy may not be correct if it fails here. data, err := c.ncli.GetConfig(param) - // the nacos client has handled the not exist error. if err != nil { - panic(err) + // If the initial connection fails and the reconnection is successful, the callback handler can also be invoked. + // Ignore the error here and print the error info. + klog.Errorf("get config %v from nacos failed %v", param, err) } callback(data, c.parser)