PhilYue commented on a change in pull request #310:
URL: https://github.com/apache/dubbo-go-pixiu/pull/310#discussion_r759941650



##########
File path: pkg/router/route.go
##########
@@ -26,131 +26,117 @@ import (
 import (
        "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
        "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/router"
-
-       "github.com/emirpasic/gods/trees/avltree"
-
        "github.com/pkg/errors"
 )
 
 import (
        "github.com/apache/dubbo-go-pixiu/pkg/common/constant"
+       "github.com/apache/dubbo-go-pixiu/pkg/common/router/trie"
+       "github.com/apache/dubbo-go-pixiu/pkg/common/util/stringutil"
 )
 
 // Node defines the single method of the router configured API
 type Node struct {
        fullPath string
-       wildcard bool
        filters  []string
-       methods  map[config.HTTPVerb]*config.Method
+       method   *config.Method
        headers  map[string]string
 }
 
 // Route defines the tree of router APIs
 type Route struct {
-       lock         sync.RWMutex
-       tree         *avltree.Tree
-       wildcardTree *avltree.Tree
+       lock sync.RWMutex
+       tree trie.Trie
 }
 
 // ClearAPI clear the api
 func (rt *Route) ClearAPI() error {
        rt.lock.Lock()
        defer rt.lock.Unlock()
-       rt.wildcardTree.Clear()
        rt.tree.Clear()
        return nil
 }
 
 func (r *Route) RemoveAPI(api router.API) {
-       fullPath := api.URLPattern
-       node, ok := r.findNode(fullPath)
-       if !ok {
-               return
-       }
-       if tempMethod, ok := node.methods[api.HTTPVerb]; ok {
-               splitedURLs := 
strings.Split(tempMethod.IntegrationRequest.HTTPBackendConfig.URL, ",")
-               afterRemoveedURL := make([]string, 0, len(splitedURLs))
-               for _, v := range splitedURLs {
-                       if v != api.IntegrationRequest.HTTPBackendConfig.URL {
-                               afterRemoveedURL = append(afterRemoveedURL, v)
-                       }
-               }
-               if len(afterRemoveedURL) == 0 {
-                       delete(node.methods, api.HTTPVerb)
+       lowerCasePath := strings.ToLower(api.URLPattern)
+       key := getTrieKey(api.Method.HTTPVerb, lowerCasePath, false)
+       _, _ = r.tree.Remove(key)

Review comment:
       这里 remove 操作是否要加锁🔐 ?




-- 
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]

Reply via email to