MasterKenway commented on code in PR #440:
URL: https://github.com/apache/dubbo-go-pixiu/pull/440#discussion_r894984121
##########
pkg/router/route.go:
##########
@@ -58,12 +59,54 @@ func (rt *Route) ClearAPI() error {
return nil
}
-func (r *Route) RemoveAPI(api router.API) {
- r.lock.Lock()
- defer r.lock.Unlock()
+func (rt *Route) RemoveAPI(api router.API) {
lowerCasePath := strings.ToLower(api.URLPattern)
key := getTrieKey(api.Method.HTTPVerb, lowerCasePath, false)
- _, _ = r.tree.Remove(key)
+
+ rt.lock.Lock()
+ defer rt.lock.Unlock()
+ // if api is exists
+ if exists, err := rt.tree.Contains(key); err != nil {
+ logger.Errorf("rt.tree.Get(key) err: %s", err.Error())
+ return
+ } else if exists {
+ // append new cluster to the node
Review Comment:
我们的负载均衡是根据 Trie Tree 叶子节点中的 mehtod.URL
属性来获取服务提供者,原本单纯的将叶子节点进行替换会导致之前订阅到的服务器提供者被覆盖,这里的删除则是避免其中一个服务器提供者下线后,不导致所有对端服务都从
Trie Tree中移除(这里的注释直接复制了上面的代码,我会在后面的 commit 修改)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]