diff --git a/cluster/directory/base_directory.go b/cluster/directory/base_directory.go index ed9c53578b766f6526937a767e0735c4b14ac3ce..ce5a09be9d78d7e2fa41a11a87e2ab4ed3a5e5a2 100644 --- a/cluster/directory/base_directory.go +++ b/cluster/directory/base_directory.go @@ -37,7 +37,7 @@ import ( 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 { url *common.URL destroyed *atomic.Bool @@ -46,12 +46,12 @@ type BaseDirectory struct { routerChain router.Chain } -// RouterChain return router chain in directory +// RouterChain Return router chain in directory func (dir *BaseDirectory) RouterChain() router.Chain { return dir.routerChain } -// SetRouterChain set router chain in directory +// SetRouterChain Set router chain in directory func (dir *BaseDirectory) SetRouterChain(routerChain router.Chain) { dir.mutex.Lock() defer dir.mutex.Unlock() @@ -77,7 +77,7 @@ func (dir *BaseDirectory) GetDirectoryUrl() *common.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) { if len(urls) == 0 { return @@ -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 { return !dir.destroyed.Load() } -// GetRouterURLSet return router URL +// GetRouterURLSet Return router URL func GetRouterURLSet() *gxset.HashSet { return routerURLSet } -// AddRouterURLSet add router URL -// router URL will init in config/config_loader.go +// AddRouterURLSet Add router URL +// Router URL will init in config/config_loader.go func AddRouterURLSet(url *common.URL) { routerURLSet.Add(url) } diff --git a/cluster/router/chain/chain.go b/cluster/router/chain/chain.go index 6f6e280b725caf4c2fbe890b11f3b4cdbbc49fa4..5c9cca10fca8a77a4d95768f59da8373decc23d2 100644 --- a/cluster/router/chain/chain.go +++ b/cluster/router/chain/chain.go @@ -36,9 +36,9 @@ import ( // RouterChain Router chain 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 - //containing all routers, reconstruct every time 'route://' urls change. + // Containing all routers, reconstruct every time 'route://' urls change. routers []router.Router // Fixed router instances: ConfigConditionRouter, TagRouter, e.g., the rule for each instance may change but the // instance will never delete or recreate. diff --git a/cluster/router/condition/router.go b/cluster/router/condition/router.go index 4dd3736b007e8e09067a289fba65b0658c1eff50..98ff3ccd9924bca87b7c3a5c617b7e859a57d5d4 100644 --- a/cluster/router/condition/router.go +++ b/cluster/router/condition/router.go @@ -45,7 +45,7 @@ var ( routerPatternReg = regexp.MustCompile(`([&!=,]*)\s*([^&!=,\s]+)`) ) -//ConditionRouter condition router struct +// ConditionRouter Condition router struct type ConditionRouter struct { Pattern string url *common.URL @@ -56,7 +56,7 @@ type ConditionRouter struct { ThenCondition map[string]MatchPair } -//NewConditionRouterWithRule Init condition router by raw rule +// NewConditionRouterWithRule Init condition router by raw rule func NewConditionRouterWithRule(rule string) (*ConditionRouter, error) { var ( whenRule string @@ -102,7 +102,7 @@ func NewConditionRouterWithRule(rule string) (*ConditionRouter, error) { }, nil } -//NewConditionRouter Init condition router by URL +// NewConditionRouter Init condition router by URL func NewConditionRouter(url *common.URL) (*ConditionRouter, error) { rule, err := url.GetParamAndDecoded(constant.RULE_KEY) @@ -289,7 +289,7 @@ func matchCondition(pairs map[string]MatchPair, url *common.URL, param *common.U return result } -// MatchPair ... +// MatchPair Match key pair , condition process type MatchPair struct { Matches *gxset.HashSet Mismatches *gxset.HashSet diff --git a/cluster/router/condition/router_rule.go b/cluster/router/condition/router_rule.go index ed0ae75488682136352dc64ed3ac5bba6d132a1c..1a4fd54a7d882752e07b375c576bdbbd1e9732b9 100644 --- a/cluster/router/condition/router_rule.go +++ b/cluster/router/condition/router_rule.go @@ -21,7 +21,7 @@ import ( "github.com/apache/dubbo-go/cluster/router" ) -// RouterRule +// RouterRule RouterRule config read from config file or config center type RouterRule struct { router.BaseRouterRule `yaml:",inline""` Conditions []string diff --git a/cluster/router/router.go b/cluster/router/router.go index f89eab8b88617f74e3fc90c1bc267bc1d1cc384e..7a9178e97e2142b93e210a53479437d403bd547b 100644 --- a/cluster/router/router.go +++ b/cluster/router/router.go @@ -24,8 +24,9 @@ import ( // Extension - Router -// RouterFactory ... +// RouterFactory Router create factory type RouterFactory interface { + // NewRouter Create router instance with URL NewRouter(*common.URL) (Router, error) } diff --git a/common/url.go b/common/url.go index 2e0798c5b0413d86c4d3b6a8a3f818a2d28caab2..7ede3d94fb321d0f5364f408327f591774f25652 100644 --- a/common/url.go +++ b/common/url.go @@ -59,7 +59,7 @@ const ( var ( // DubboNodes ... DubboNodes = [...]string{"consumers", "configurators", "routers", "providers"} - // DubboRole dubbo service role + // DubboRole Dubbo service role DubboRole = [...]string{"consumer", "", "routers", "provider"} )