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

fix review problems

parent 085961b4
No related branches found
No related tags found
No related merge requests found
......@@ -83,7 +83,7 @@ func (invoker *failoverClusterInvoker) Invoke(invocation protocol.Invocation) pr
if err != nil {
return &protocol.RPCResult{Err: err}
}
invokers := invoker.directory.List(invocation)
invokers = invoker.directory.List(invocation)
err = invoker.checkInvokers(invokers, invocation)
if err != nil {
return &protocol.RPCResult{Err: err}
......
......@@ -21,32 +21,30 @@ import (
"sync"
)
import (
"github.com/apache/dubbo-go/cluster"
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/extension"
"github.com/dubbogo/gost/container/gxset"
"go.uber.org/atomic"
)
import (
"github.com/apache/dubbo-go/cluster"
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/extension"
"github.com/dubbogo/gost/container/gxset"
)
var RouterUrlSet = gxset.NewSet()
type BaseDirectory struct {
url *common.URL
ConsumerUrl *common.URL
destroyed *atomic.Bool
routers []cluster.Router
mutex sync.Mutex
once sync.Once
url *common.URL
destroyed *atomic.Bool
routers []cluster.Router
mutex sync.Mutex
once sync.Once
}
func NewBaseDirectory(url *common.URL) BaseDirectory {
return BaseDirectory{
url: url,
ConsumerUrl: url,
destroyed: atomic.NewBool(false),
url: url,
destroyed: atomic.NewBool(false),
}
}
func (dir *BaseDirectory) Destroyed() bool {
......
......@@ -67,7 +67,7 @@ func (dir *staticDirectory) List(invocation protocol.Invocation) []protocol.Invo
}
for _, router := range localRouters {
if reflect.ValueOf(router.Url()).IsNil() || router.Url().GetParamBool(constant.RUNTIME_KEY, false) {
return router.Route(invokers, *dir.ConsumerUrl, invocation)
return router.Route(invokers, dir.GetUrl(), invocation)
}
}
return invokers
......
......@@ -22,8 +22,6 @@ import (
"reflect"
"sync"
"time"
"github.com/apache/dubbo-go/cluster"
)
import (
......@@ -32,6 +30,7 @@ import (
)
import (
"github.com/apache/dubbo-go/cluster"
"github.com/apache/dubbo-go/cluster/directory"
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/constant"
......@@ -247,11 +246,11 @@ func (dir *registryDirectory) List(invocation protocol.Invocation) []protocol.In
invokers := dir.cacheInvokers
localRouters := dir.Routers()
fmt.Println("========", len(localRouters))
logger.Debug("========", len(localRouters))
if len(localRouters) > 0 {
for _, router := range localRouters {
if reflect.ValueOf(router.Url()).IsValid() || router.Url().GetParamBool(constant.RUNTIME_KEY, false) {
invokers = router.Route(invokers, *dir.ConsumerUrl, invocation)
invokers = router.Route(invokers, dir.GetUrl(), invocation)
}
}
}
......
......@@ -118,8 +118,7 @@ func Test_List(t *testing.T) {
registryDirectory, _ := normalRegistryDir()
time.Sleep(1e9)
invokers := registryDirectory.List(&invocation.RPCInvocation{})
assert.Len(t, invokers, 3)
assert.Len(t, registryDirectory.List(&invocation.RPCInvocation{}), 3)
assert.Equal(t, true, registryDirectory.IsAvailable())
}
......
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