Skip to content
Snippets Groups Projects
Commit 0a49c7b2 authored by 邹毅贤's avatar 邹毅贤
Browse files

remove router chain

parent 1d92adfb
No related branches found
No related tags found
No related merge requests found
...@@ -19,8 +19,6 @@ package directory ...@@ -19,8 +19,6 @@ package directory
import ( import (
"sync" "sync"
"github.com/apache/dubbo-go/cluster/router/router_chain"
) )
import ( import (
"go.uber.org/atomic" "go.uber.org/atomic"
...@@ -36,12 +34,11 @@ import ( ...@@ -36,12 +34,11 @@ import (
var RouterUrlSet = gxset.NewSet() var RouterUrlSet = gxset.NewSet()
type BaseDirectory struct { type BaseDirectory struct {
url *common.URL url *common.URL
destroyed *atomic.Bool destroyed *atomic.Bool
routers []cluster.Router routers []cluster.Router
mutex sync.Mutex mutex sync.Mutex
once sync.Once once sync.Once
routerChain *router_chain.RouterChain
} }
func NewBaseDirectory(url *common.URL) BaseDirectory { func NewBaseDirectory(url *common.URL) BaseDirectory {
......
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)
}*/
}
...@@ -20,13 +20,10 @@ package protocol ...@@ -20,13 +20,10 @@ package protocol
import ( import (
"strings" "strings"
"sync" "sync"
"github.com/apache/dubbo-go/cluster"
"github.com/apache/dubbo-go/cluster/router/router_chain"
) )
import ( import (
gxset "github.com/dubbogo/gost/container/set" "github.com/dubbogo/gost/container/gxset"
) )
import ( import (
...@@ -124,10 +121,6 @@ func (proto *registryProtocol) Refer(url common.URL) protocol.Invoker { ...@@ -124,10 +121,6 @@ func (proto *registryProtocol) Refer(url common.URL) protocol.Invoker {
} }
go directory.Subscribe(serviceUrl) go directory.Subscribe(serviceUrl)
chain := router_chain.NewRouterChain(serviceUrl)
if chain != nil {
//directory.SetRouters(chain.)
}
//new cluster invoker //new cluster invoker
cluster := extension.GetCluster(serviceUrl.GetParam(constant.CLUSTER_KEY, constant.DEFAULT_CLUSTER)) cluster := extension.GetCluster(serviceUrl.GetParam(constant.CLUSTER_KEY, constant.DEFAULT_CLUSTER))
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment