diff --git a/cluster/directory/base_directory.go b/cluster/directory/base_directory.go index 353e10a6869d4fe642febbe9e98751fad253c04e..5ad9c0f646fb5a748bca41ea1b7a03fd7d6126b3 100644 --- a/cluster/directory/base_directory.go +++ b/cluster/directory/base_directory.go @@ -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() } diff --git a/cluster/directory/static_directory.go b/cluster/directory/static_directory.go index abe03db90acad0002be0671f784bb81e2931d42d..032859a278b938025668cad408f1297f2c2f0b02 100644 --- a/cluster/directory/static_directory.go +++ b/cluster/directory/static_directory.go @@ -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 { diff --git a/cluster/router/condition/listenable_router.go b/cluster/router/condition/listenable_router.go index 4b7b56ff97b9cdb9daed1f0d842615a6948394e1..933dc5f32cf86f63fb98a12b292e470fc23d4be0 100644 --- a/cluster/router/condition/listenable_router.go +++ b/cluster/router/condition/listenable_router.go @@ -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 { diff --git a/cluster/router/match/match_utils_test.go b/cluster/router/match/match_utils_test.go index e36d68fa9cd6cc8f06c775f354f38eebd3e6241d..f16480f1d3b7dd5ca820c81d5d04d837c129687f 100644 --- a/cluster/router/match/match_utils_test.go +++ b/cluster/router/match/match_utils_test.go @@ -18,7 +18,6 @@ package match import ( - "context" "testing" )