Skip to content
Snippets Groups Projects
Commit 6c61c91e authored by Xin.Zh's avatar Xin.Zh Committed by GitHub
Browse files

Merge pull request #333 from weiwei-xiao/feature/add_comment_for_exported_by_golint

GOLINT: add comment for exported (checked by golint)
parents 2cf097e8 62db65d1
No related branches found
No related tags found
No related merge requests found
Showing
with 35 additions and 0 deletions
...@@ -21,6 +21,7 @@ import ( ...@@ -21,6 +21,7 @@ import (
"github.com/apache/dubbo-go/protocol" "github.com/apache/dubbo-go/protocol"
) )
// Cluster ...
type Cluster interface { type Cluster interface {
Join(Directory) protocol.Invoker Join(Directory) protocol.Invoker
} }
...@@ -31,6 +31,7 @@ func init() { ...@@ -31,6 +31,7 @@ func init() {
extension.SetCluster(available, NewAvailableCluster) extension.SetCluster(available, NewAvailableCluster)
} }
// NewAvailableCluster ...
func NewAvailableCluster() cluster.Cluster { func NewAvailableCluster() cluster.Cluster {
return &availableCluster{} return &availableCluster{}
} }
......
...@@ -35,6 +35,7 @@ type availableClusterInvoker struct { ...@@ -35,6 +35,7 @@ type availableClusterInvoker struct {
baseClusterInvoker baseClusterInvoker
} }
// NewAvailableClusterInvoker ...
func NewAvailableClusterInvoker(directory cluster.Directory) protocol.Invoker { func NewAvailableClusterInvoker(directory cluster.Directory) protocol.Invoker {
return &availableClusterInvoker{ return &availableClusterInvoker{
baseClusterInvoker: newBaseClusterInvoker(directory), baseClusterInvoker: newBaseClusterInvoker(directory),
......
...@@ -31,6 +31,7 @@ func init() { ...@@ -31,6 +31,7 @@ func init() {
extension.SetCluster(broadcast, NewBroadcastCluster) extension.SetCluster(broadcast, NewBroadcastCluster)
} }
// NewBroadcastCluster ...
func NewBroadcastCluster() cluster.Cluster { func NewBroadcastCluster() cluster.Cluster {
return &broadcastCluster{} return &broadcastCluster{}
} }
......
...@@ -31,6 +31,7 @@ func init() { ...@@ -31,6 +31,7 @@ func init() {
extension.SetCluster(failback, NewFailbackCluster) extension.SetCluster(failback, NewFailbackCluster)
} }
// NewFailbackCluster ...
func NewFailbackCluster() cluster.Cluster { func NewFailbackCluster() cluster.Cluster {
return &failbackCluster{} return &failbackCluster{}
} }
......
...@@ -31,6 +31,7 @@ func init() { ...@@ -31,6 +31,7 @@ func init() {
extension.SetCluster(failfast, NewFailFastCluster) extension.SetCluster(failfast, NewFailFastCluster)
} }
// NewFailFastCluster ...
func NewFailFastCluster() cluster.Cluster { func NewFailFastCluster() cluster.Cluster {
return &failfastCluster{} return &failfastCluster{}
} }
......
...@@ -31,6 +31,7 @@ func init() { ...@@ -31,6 +31,7 @@ func init() {
extension.SetCluster(name, NewFailoverCluster) extension.SetCluster(name, NewFailoverCluster)
} }
// NewFailoverCluster ...
func NewFailoverCluster() cluster.Cluster { func NewFailoverCluster() cluster.Cluster {
return &failoverCluster{} return &failoverCluster{}
} }
......
...@@ -31,6 +31,7 @@ func init() { ...@@ -31,6 +31,7 @@ func init() {
extension.SetCluster(failsafe, NewFailsafeCluster) extension.SetCluster(failsafe, NewFailsafeCluster)
} }
// NewFailsafeCluster ...
func NewFailsafeCluster() cluster.Cluster { func NewFailsafeCluster() cluster.Cluster {
return &failsafeCluster{} return &failsafeCluster{}
} }
......
...@@ -31,6 +31,7 @@ func init() { ...@@ -31,6 +31,7 @@ func init() {
extension.SetCluster(forking, NewForkingCluster) extension.SetCluster(forking, NewForkingCluster)
} }
// NewForkingCluster ...
func NewForkingCluster() cluster.Cluster { func NewForkingCluster() cluster.Cluster {
return &forkingCluster{} return &forkingCluster{}
} }
......
...@@ -24,6 +24,7 @@ import ( ...@@ -24,6 +24,7 @@ import (
type mockCluster struct{} type mockCluster struct{}
// NewMockCluster ...
func NewMockCluster() cluster.Cluster { func NewMockCluster() cluster.Cluster {
return &mockCluster{} return &mockCluster{}
} }
......
...@@ -29,6 +29,7 @@ func init() { ...@@ -29,6 +29,7 @@ func init() {
extension.SetCluster("registryAware", NewRegistryAwareCluster) extension.SetCluster("registryAware", NewRegistryAwareCluster)
} }
// NewRegistryAwareCluster ...
func NewRegistryAwareCluster() cluster.Cluster { func NewRegistryAwareCluster() cluster.Cluster {
return &registryAwareCluster{} return &registryAwareCluster{}
} }
......
...@@ -27,25 +27,32 @@ import ( ...@@ -27,25 +27,32 @@ import (
"github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/common"
) )
// BaseDirectory ...
type BaseDirectory struct { type BaseDirectory struct {
url *common.URL url *common.URL
destroyed *atomic.Bool destroyed *atomic.Bool
mutex sync.Mutex mutex sync.Mutex
} }
// NewBaseDirectory ...
func NewBaseDirectory(url *common.URL) BaseDirectory { func NewBaseDirectory(url *common.URL) BaseDirectory {
return BaseDirectory{ return BaseDirectory{
url: url, url: url,
destroyed: atomic.NewBool(false), destroyed: atomic.NewBool(false),
} }
} }
// GetUrl ...
func (dir *BaseDirectory) GetUrl() common.URL { func (dir *BaseDirectory) GetUrl() common.URL {
return *dir.url return *dir.url
} }
// GetDirectoryUrl ...
func (dir *BaseDirectory) GetDirectoryUrl() *common.URL { func (dir *BaseDirectory) GetDirectoryUrl() *common.URL {
return dir.url return dir.url
} }
// Destroy ...
func (dir *BaseDirectory) Destroy(doDestroy func()) { func (dir *BaseDirectory) Destroy(doDestroy func()) {
if dir.destroyed.CAS(false, true) { if dir.destroyed.CAS(false, true) {
dir.mutex.Lock() dir.mutex.Lock()
...@@ -54,6 +61,7 @@ func (dir *BaseDirectory) Destroy(doDestroy func()) { ...@@ -54,6 +61,7 @@ func (dir *BaseDirectory) Destroy(doDestroy func()) {
} }
} }
// IsAvailable ...
func (dir *BaseDirectory) IsAvailable() bool { func (dir *BaseDirectory) IsAvailable() bool {
return !dir.destroyed.Load() return !dir.destroyed.Load()
} }
...@@ -27,6 +27,7 @@ type staticDirectory struct { ...@@ -27,6 +27,7 @@ type staticDirectory struct {
invokers []protocol.Invoker invokers []protocol.Invoker
} }
// NewStaticDirectory ...
func NewStaticDirectory(invokers []protocol.Invoker) *staticDirectory { func NewStaticDirectory(invokers []protocol.Invoker) *staticDirectory {
var url common.URL var url common.URL
......
...@@ -50,13 +50,16 @@ func init() { ...@@ -50,13 +50,16 @@ func init() {
extension.SetLoadbalance(ConsistentHash, NewConsistentHashLoadBalance) extension.SetLoadbalance(ConsistentHash, NewConsistentHashLoadBalance)
} }
// ConsistentHashLoadBalance ...
type ConsistentHashLoadBalance struct { type ConsistentHashLoadBalance struct {
} }
// NewConsistentHashLoadBalance ...
func NewConsistentHashLoadBalance() cluster.LoadBalance { func NewConsistentHashLoadBalance() cluster.LoadBalance {
return &ConsistentHashLoadBalance{} return &ConsistentHashLoadBalance{}
} }
// Select ...
func (lb *ConsistentHashLoadBalance) Select(invokers []protocol.Invoker, invocation protocol.Invocation) protocol.Invoker { func (lb *ConsistentHashLoadBalance) Select(invokers []protocol.Invoker, invocation protocol.Invocation) protocol.Invoker {
methodName := invocation.MethodName() methodName := invocation.MethodName()
key := invokers[0].GetUrl().ServiceKey() + "." + methodName key := invokers[0].GetUrl().ServiceKey() + "." + methodName
...@@ -79,6 +82,7 @@ func (lb *ConsistentHashLoadBalance) Select(invokers []protocol.Invoker, invocat ...@@ -79,6 +82,7 @@ func (lb *ConsistentHashLoadBalance) Select(invokers []protocol.Invoker, invocat
return selector.Select(invocation) return selector.Select(invocation)
} }
// Uint32Slice ...
type Uint32Slice []uint32 type Uint32Slice []uint32
func (s Uint32Slice) Len() int { func (s Uint32Slice) Len() int {
...@@ -93,6 +97,7 @@ func (s Uint32Slice) Swap(i, j int) { ...@@ -93,6 +97,7 @@ func (s Uint32Slice) Swap(i, j int) {
s[i], s[j] = s[j], s[i] s[i], s[j] = s[j], s[i]
} }
// ConsistentHashSelector ...
type ConsistentHashSelector struct { type ConsistentHashSelector struct {
hashCode uint32 hashCode uint32
replicaNum int replicaNum int
...@@ -133,6 +138,7 @@ func newConsistentHashSelector(invokers []protocol.Invoker, methodName string, ...@@ -133,6 +138,7 @@ func newConsistentHashSelector(invokers []protocol.Invoker, methodName string,
return selector return selector
} }
// Select ...
func (c *ConsistentHashSelector) Select(invocation protocol.Invocation) protocol.Invoker { func (c *ConsistentHashSelector) Select(invocation protocol.Invocation) protocol.Invoker {
key := c.toKey(invocation.Arguments()) key := c.toKey(invocation.Arguments())
digest := md5.Sum([]byte(key)) digest := md5.Sum([]byte(key))
......
...@@ -38,6 +38,7 @@ func init() { ...@@ -38,6 +38,7 @@ func init() {
type leastActiveLoadBalance struct { type leastActiveLoadBalance struct {
} }
// NewLeastActiveLoadBalance ...
func NewLeastActiveLoadBalance() cluster.LoadBalance { func NewLeastActiveLoadBalance() cluster.LoadBalance {
return &leastActiveLoadBalance{} return &leastActiveLoadBalance{}
} }
......
...@@ -38,6 +38,7 @@ func init() { ...@@ -38,6 +38,7 @@ func init() {
type randomLoadBalance struct { type randomLoadBalance struct {
} }
// NewRandomLoadBalance ...
func NewRandomLoadBalance() cluster.LoadBalance { func NewRandomLoadBalance() cluster.LoadBalance {
return &randomLoadBalance{} return &randomLoadBalance{}
} }
......
...@@ -49,6 +49,7 @@ func init() { ...@@ -49,6 +49,7 @@ func init() {
type roundRobinLoadBalance struct{} type roundRobinLoadBalance struct{}
// NewRoundRobinLoadBalance ...
func NewRoundRobinLoadBalance() cluster.LoadBalance { func NewRoundRobinLoadBalance() cluster.LoadBalance {
return &roundRobinLoadBalance{} return &roundRobinLoadBalance{}
} }
......
...@@ -26,6 +26,7 @@ import ( ...@@ -26,6 +26,7 @@ import (
"github.com/apache/dubbo-go/protocol" "github.com/apache/dubbo-go/protocol"
) )
// GetWeight ...
func GetWeight(invoker protocol.Invoker, invocation protocol.Invocation) int64 { func GetWeight(invoker protocol.Invoker, invocation protocol.Invocation) int64 {
url := invoker.GetUrl() url := invoker.GetUrl()
weight := url.GetMethodParamInt64(invocation.MethodName(), constant.WEIGHT_KEY, constant.DEFAULT_WEIGHT) weight := url.GetMethodParamInt64(invocation.MethodName(), constant.WEIGHT_KEY, constant.DEFAULT_WEIGHT)
......
...@@ -24,18 +24,22 @@ import ( ...@@ -24,18 +24,22 @@ import (
// Extension - Router // Extension - Router
// RouterFactory ...
type RouterFactory interface { type RouterFactory interface {
Router(*common.URL) (Router, error) Router(*common.URL) (Router, error)
} }
// Router ...
type Router interface { type Router interface {
Route([]protocol.Invoker, common.URL, protocol.Invocation) []protocol.Invoker Route([]protocol.Invoker, common.URL, protocol.Invocation) []protocol.Invoker
} }
// RouterChain ...
type RouterChain struct { type RouterChain struct {
routers []Router routers []Router
} }
// NewRouterChain ...
func NewRouterChain(url common.URL) { func NewRouterChain(url common.URL) {
} }
...@@ -259,6 +259,7 @@ func MatchCondition(pairs map[string]MatchPair, url *common.URL, param *common.U ...@@ -259,6 +259,7 @@ func MatchCondition(pairs map[string]MatchPair, url *common.URL, param *common.U
return result, nil return result, nil
} }
// MatchPair ...
type MatchPair struct { type MatchPair struct {
Matches *gxset.HashSet Matches *gxset.HashSet
Mismatches *gxset.HashSet Mismatches *gxset.HashSet
......
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