From 0a49c7b2254c733e9a564169ebc50954dd80837d Mon Sep 17 00:00:00 2001 From: Joe Zou <yixian.zou@gmail.com> Date: Thu, 9 Jan 2020 14:23:11 +0800 Subject: [PATCH] remove router chain --- cluster/directory/base_directory.go | 13 +++--- cluster/router/router_chain/router_chain.go | 49 --------------------- registry/protocol/protocol.go | 9 +--- 3 files changed, 6 insertions(+), 65 deletions(-) delete mode 100644 cluster/router/router_chain/router_chain.go diff --git a/cluster/directory/base_directory.go b/cluster/directory/base_directory.go index 98b392221..ac7b04fa3 100644 --- a/cluster/directory/base_directory.go +++ b/cluster/directory/base_directory.go @@ -19,8 +19,6 @@ package directory import ( "sync" - - "github.com/apache/dubbo-go/cluster/router/router_chain" ) import ( "go.uber.org/atomic" @@ -36,12 +34,11 @@ import ( var RouterUrlSet = gxset.NewSet() type BaseDirectory struct { - url *common.URL - destroyed *atomic.Bool - routers []cluster.Router - mutex sync.Mutex - once sync.Once - routerChain *router_chain.RouterChain + url *common.URL + destroyed *atomic.Bool + routers []cluster.Router + mutex sync.Mutex + once sync.Once } func NewBaseDirectory(url *common.URL) BaseDirectory { diff --git a/cluster/router/router_chain/router_chain.go b/cluster/router/router_chain/router_chain.go deleted file mode 100644 index dab644db6..000000000 --- a/cluster/router/router_chain/router_chain.go +++ /dev/null @@ -1,49 +0,0 @@ -package router_chain - -import ( - "sort" -) -import ( - "github.com/apache/dubbo-go/cluster" - "github.com/apache/dubbo-go/common" - "github.com/apache/dubbo-go/common/extension" - "github.com/apache/dubbo-go/protocol" -) - -type RouterChain struct { - routers []cluster.Router - builtinRouters []cluster.Router - Invokers []protocol.Invoker -} - -func NewRouterChain(url *common.URL) *RouterChain { - var builtinRouters []cluster.Router - factories := extension.GetRouterFactories() - for _, factory := range factories { - router, _ := factory.Router(url) - builtinRouters = append(builtinRouters, router) - } - var routers []cluster.Router - copy(routers, builtinRouters) - sort.SliceStable(routers, func(i, j int) bool { - return routers[i].Priority() < routers[j].Priority() - }) - return &RouterChain{ - builtinRouters: builtinRouters, - routers: routers, - } -} - -func (r RouterChain) AddRouters(routers []cluster.Router) { - r.routers = append(r.routers, routers...) - sort.SliceStable(r.routers, func(i, j int) bool { - return routers[i].Priority() < routers[j].Priority() - }) -} - -func (r RouterChain) SetInvokers(invokers []protocol.Invoker) { - r.Invokers = invokers - /*for _, _ := range r.routers { - //router.Notify(r.Invokers) - }*/ -} diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index 5246bfc15..534a4b945 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -20,13 +20,10 @@ package protocol import ( "strings" "sync" - - "github.com/apache/dubbo-go/cluster" - "github.com/apache/dubbo-go/cluster/router/router_chain" ) import ( - gxset "github.com/dubbogo/gost/container/set" + "github.com/dubbogo/gost/container/gxset" ) import ( @@ -124,10 +121,6 @@ func (proto *registryProtocol) Refer(url common.URL) protocol.Invoker { } go directory.Subscribe(serviceUrl) - chain := router_chain.NewRouterChain(serviceUrl) - if chain != nil { - //directory.SetRouters(chain.) - } //new cluster invoker cluster := extension.GetCluster(serviceUrl.GetParam(constant.CLUSTER_KEY, constant.DEFAULT_CLUSTER)) -- GitLab