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

fix review comment

parent 26d7af9b
No related branches found
No related tags found
No related merge requests found
...@@ -37,7 +37,7 @@ import ( ...@@ -37,7 +37,7 @@ import (
var routerURLSet = gxset.NewSet() var routerURLSet = gxset.NewSet()
// BaseDirectory Abstract implementation of Directory: Invoker list returned from this Directory's list method have been filtered by Routers // BaseDirectory Abstract implementation of Directory: Invoker list returned from this Directory's list method have been filtered by Routers
type BaseDirectory struct { type BaseDirectory struct {
url *common.URL url *common.URL
destroyed *atomic.Bool destroyed *atomic.Bool
...@@ -46,12 +46,12 @@ type BaseDirectory struct { ...@@ -46,12 +46,12 @@ type BaseDirectory struct {
routerChain router.Chain routerChain router.Chain
} }
// RouterChain return router chain in directory // RouterChain Return router chain in directory
func (dir *BaseDirectory) RouterChain() router.Chain { func (dir *BaseDirectory) RouterChain() router.Chain {
return dir.routerChain return dir.routerChain
} }
// SetRouterChain set router chain in directory // SetRouterChain Set router chain in directory
func (dir *BaseDirectory) SetRouterChain(routerChain router.Chain) { func (dir *BaseDirectory) SetRouterChain(routerChain router.Chain) {
dir.mutex.Lock() dir.mutex.Lock()
defer dir.mutex.Unlock() defer dir.mutex.Unlock()
...@@ -77,7 +77,7 @@ func (dir *BaseDirectory) GetDirectoryUrl() *common.URL { ...@@ -77,7 +77,7 @@ func (dir *BaseDirectory) GetDirectoryUrl() *common.URL {
return dir.url return dir.url
} }
// SetRouters convert url to routers and add them into dir.routerChain // SetRouters Convert url to routers and add them into dir.routerChain
func (dir *BaseDirectory) SetRouters(urls []*common.URL) { func (dir *BaseDirectory) SetRouters(urls []*common.URL) {
if len(urls) == 0 { if len(urls) == 0 {
return return
...@@ -116,18 +116,18 @@ func (dir *BaseDirectory) Destroy(doDestroy func()) { ...@@ -116,18 +116,18 @@ func (dir *BaseDirectory) Destroy(doDestroy func()) {
} }
} }
// IsAvailable Once directory init finish, it will change to true // IsAvailable Once directory init finish, it will change to true
func (dir *BaseDirectory) IsAvailable() bool { func (dir *BaseDirectory) IsAvailable() bool {
return !dir.destroyed.Load() return !dir.destroyed.Load()
} }
// GetRouterURLSet return router URL // GetRouterURLSet Return router URL
func GetRouterURLSet() *gxset.HashSet { func GetRouterURLSet() *gxset.HashSet {
return routerURLSet return routerURLSet
} }
// AddRouterURLSet add router URL // AddRouterURLSet Add router URL
// router URL will init in config/config_loader.go // Router URL will init in config/config_loader.go
func AddRouterURLSet(url *common.URL) { func AddRouterURLSet(url *common.URL) {
routerURLSet.Add(url) routerURLSet.Add(url)
} }
...@@ -36,9 +36,9 @@ import ( ...@@ -36,9 +36,9 @@ import (
// RouterChain Router chain // RouterChain Router chain
type RouterChain struct { type RouterChain struct {
//full list of addresses from registry, classified by method name. // Full list of addresses from registry, classified by method name.
invokers []protocol.Invoker invokers []protocol.Invoker
//containing all routers, reconstruct every time 'route://' urls change. // Containing all routers, reconstruct every time 'route://' urls change.
routers []router.Router routers []router.Router
// Fixed router instances: ConfigConditionRouter, TagRouter, e.g., the rule for each instance may change but the // Fixed router instances: ConfigConditionRouter, TagRouter, e.g., the rule for each instance may change but the
// instance will never delete or recreate. // instance will never delete or recreate.
......
...@@ -45,7 +45,7 @@ var ( ...@@ -45,7 +45,7 @@ var (
routerPatternReg = regexp.MustCompile(`([&!=,]*)\s*([^&!=,\s]+)`) routerPatternReg = regexp.MustCompile(`([&!=,]*)\s*([^&!=,\s]+)`)
) )
//ConditionRouter condition router struct // ConditionRouter Condition router struct
type ConditionRouter struct { type ConditionRouter struct {
Pattern string Pattern string
url *common.URL url *common.URL
...@@ -56,7 +56,7 @@ type ConditionRouter struct { ...@@ -56,7 +56,7 @@ type ConditionRouter struct {
ThenCondition map[string]MatchPair ThenCondition map[string]MatchPair
} }
//NewConditionRouterWithRule Init condition router by raw rule // NewConditionRouterWithRule Init condition router by raw rule
func NewConditionRouterWithRule(rule string) (*ConditionRouter, error) { func NewConditionRouterWithRule(rule string) (*ConditionRouter, error) {
var ( var (
whenRule string whenRule string
...@@ -102,7 +102,7 @@ func NewConditionRouterWithRule(rule string) (*ConditionRouter, error) { ...@@ -102,7 +102,7 @@ func NewConditionRouterWithRule(rule string) (*ConditionRouter, error) {
}, nil }, nil
} }
//NewConditionRouter Init condition router by URL // NewConditionRouter Init condition router by URL
func NewConditionRouter(url *common.URL) (*ConditionRouter, error) { func NewConditionRouter(url *common.URL) (*ConditionRouter, error) {
rule, err := url.GetParamAndDecoded(constant.RULE_KEY) rule, err := url.GetParamAndDecoded(constant.RULE_KEY)
...@@ -289,7 +289,7 @@ func matchCondition(pairs map[string]MatchPair, url *common.URL, param *common.U ...@@ -289,7 +289,7 @@ func matchCondition(pairs map[string]MatchPair, url *common.URL, param *common.U
return result return result
} }
// MatchPair ... // MatchPair Match key pair , condition process
type MatchPair struct { type MatchPair struct {
Matches *gxset.HashSet Matches *gxset.HashSet
Mismatches *gxset.HashSet Mismatches *gxset.HashSet
......
...@@ -21,7 +21,7 @@ import ( ...@@ -21,7 +21,7 @@ import (
"github.com/apache/dubbo-go/cluster/router" "github.com/apache/dubbo-go/cluster/router"
) )
// RouterRule // RouterRule RouterRule config read from config file or config center
type RouterRule struct { type RouterRule struct {
router.BaseRouterRule `yaml:",inline""` router.BaseRouterRule `yaml:",inline""`
Conditions []string Conditions []string
......
...@@ -24,8 +24,9 @@ import ( ...@@ -24,8 +24,9 @@ import (
// Extension - Router // Extension - Router
// RouterFactory ... // RouterFactory Router create factory
type RouterFactory interface { type RouterFactory interface {
// NewRouter Create router instance with URL
NewRouter(*common.URL) (Router, error) NewRouter(*common.URL) (Router, error)
} }
......
...@@ -59,7 +59,7 @@ const ( ...@@ -59,7 +59,7 @@ const (
var ( var (
// DubboNodes ... // DubboNodes ...
DubboNodes = [...]string{"consumers", "configurators", "routers", "providers"} DubboNodes = [...]string{"consumers", "configurators", "routers", "providers"}
// DubboRole dubbo service role // DubboRole Dubbo service role
DubboRole = [...]string{"consumer", "", "routers", "provider"} DubboRole = [...]string{"consumer", "", "routers", "provider"}
) )
......
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