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

fix test case and add some comment

parent 326e1fb7
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,6 @@
package directory
import (
"github.com/apache/dubbo-go/common/logger"
"sync"
)
......@@ -32,12 +31,13 @@ import (
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/extension"
"github.com/apache/dubbo-go/common/logger"
"github.com/dubbogo/gost/container/set"
)
var routerURLSet = gxset.NewSet()
// BaseDirectory ...
// BaseDirectory Abstract implementation of Directory: Invoker list returned from this Directory's list method have been filtered by Routers
type BaseDirectory struct {
url *common.URL
destroyed *atomic.Bool
......@@ -57,7 +57,7 @@ func (dir *BaseDirectory) SetRouterChain(routerChain router.Chain) {
dir.routerChain = routerChain
}
// NewBaseDirectory ...
// NewBaseDirectory Create BaseDirectory with URL
func NewBaseDirectory(url *common.URL) BaseDirectory {
return BaseDirectory{
url: url,
......@@ -66,12 +66,12 @@ func NewBaseDirectory(url *common.URL) BaseDirectory {
}
}
// GetUrl ...
// GetUrl Get URL
func (dir *BaseDirectory) GetUrl() common.URL {
return *dir.url
}
// GetDirectoryUrl ...
// GetDirectoryUrl Get URL instance
func (dir *BaseDirectory) GetDirectoryUrl() *common.URL {
return dir.url
}
......@@ -106,7 +106,7 @@ func (dir *BaseDirectory) SetRouters(urls []*common.URL) {
rc.AddRouters(routers)
}
// Destroy ...
// Destroy Destroy
func (dir *BaseDirectory) Destroy(doDestroy func()) {
if dir.destroyed.CAS(false, true) {
dir.mutex.Lock()
......@@ -115,7 +115,7 @@ func (dir *BaseDirectory) Destroy(doDestroy func()) {
}
}
// IsAvailable ...
// IsAvailable Once directory init finish, it will change to true
func (dir *BaseDirectory) IsAvailable() bool {
return !dir.destroyed.Load()
}
......
......@@ -27,7 +27,7 @@ type staticDirectory struct {
invokers []protocol.Invoker
}
// NewStaticDirectory ...
// NewStaticDirectory Create a new staticDirectory with invokers
func NewStaticDirectory(invokers []protocol.Invoker) *staticDirectory {
var url common.URL
......@@ -53,6 +53,7 @@ func (dir *staticDirectory) IsAvailable() bool {
return true
}
// List List invokers
func (dir *staticDirectory) List(invocation protocol.Invocation) []protocol.Invoker {
l := len(dir.invokers)
invokers := make([]protocol.Invoker, l, l)
......@@ -66,6 +67,7 @@ func (dir *staticDirectory) List(invocation protocol.Invocation) []protocol.Invo
return routerChain.Route(invokers, &dirUrl, invocation)
}
// Destroy Destroy
func (dir *staticDirectory) Destroy() {
dir.BaseDirectory.Destroy(func() {
for _, ivk := range dir.invokers {
......
......@@ -40,7 +40,7 @@ const (
listenableRouterDefaultPriority = ^int64(0)
)
//ListenableRouter Abstract router which listens to dynamic configuration
// listenableRouter Abstract router which listens to dynamic configuration
type listenableRouter struct {
conditionRouters []*ConditionRouter
routerRule *RouterRule
......@@ -49,6 +49,7 @@ type listenableRouter struct {
priority int64
}
// RouterRule Get RouterRule instance from listenableRouter
func (l *listenableRouter) RouterRule() *RouterRule {
return l.routerRule
}
......@@ -84,6 +85,7 @@ func newListenableRouter(url *common.URL, ruleKey string) (*AppRouter, error) {
return l, nil
}
// Process Process config change event , generate routers and set them to the listenableRouter instance
func (l *listenableRouter) Process(event *config_center.ConfigChangeEvent) {
logger.Infof("Notification of condition rule, change type is:[%s] , raw rule is:[%v]", event.ConfigType, event.Value)
if remoting.EventTypeDel == event.ConfigType {
......
......@@ -18,7 +18,6 @@
package match
import (
"context"
"testing"
)
......
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