Skip to content
Snippets Groups Projects
Commit e476820d authored by shaw's avatar shaw
Browse files

GOLINT: add comment for exported (checked by golint)

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