Skip to content

Commit

Permalink
ignore the GetConfig error and add comments
Browse files Browse the repository at this point in the history
whalecold committed Nov 1, 2023
1 parent d74d9da commit 98c0648
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions nacos/nacos.go
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 98c0648

Please sign in to comment.