Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ftr: add comment for cluster #584

Merged
merged 4 commits into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import (
"github.com/apache/dubbo-go/protocol"
)

// Cluster ...
// Cluster
// Extension - Cluster
type Cluster interface {
Join(Directory) protocol.Invoker
}
4 changes: 3 additions & 1 deletion cluster/cluster_impl/available_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ func init() {
extension.SetCluster(available, NewAvailableCluster)
}

// NewAvailableCluster ...
// NewAvailableCluster returns a cluster instance
//
// Obtain available service providers
func NewAvailableCluster() cluster.Cluster {
return &availableCluster{}
}
Expand Down
2 changes: 1 addition & 1 deletion cluster/cluster_impl/available_cluster_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type availableClusterInvoker struct {
baseClusterInvoker
}

// NewAvailableClusterInvoker ...
// NewAvailableClusterInvoker returns a cluster invoker instance
func NewAvailableClusterInvoker(directory cluster.Directory) protocol.Invoker {
return &availableClusterInvoker{
baseClusterInvoker: newBaseClusterInvoker(directory),
Expand Down
5 changes: 4 additions & 1 deletion cluster/cluster_impl/broadcast_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ func init() {
extension.SetCluster(broadcast, NewBroadcastCluster)
}

// NewBroadcastCluster ...
// NewBroadcastCluster returns a broadcast cluster instance.
//
// Calling all providers' broadcast one by one. All errors will be reported.
// It is usually used to notify all providers to update local resource information such as caches or logs.
func NewBroadcastCluster() cluster.Cluster {
return &broadcastCluster{}
}
Expand Down
5 changes: 4 additions & 1 deletion cluster/cluster_impl/failback_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ func init() {
extension.SetCluster(failback, NewFailbackCluster)
}

// NewFailbackCluster ...
// NewFailbackCluster returns a failback cluster instance
//
// Failure automatically restored, failed to record the background request,
// regular retransmission. Usually used for message notification operations.
func NewFailbackCluster() cluster.Cluster {
return &failbackCluster{}
}
Expand Down
5 changes: 4 additions & 1 deletion cluster/cluster_impl/failfast_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ func init() {
extension.SetCluster(failfast, NewFailFastCluster)
}

// NewFailFastCluster ...
// NewFailFastCluster returns a failfast cluster instance.
//
// Fast failure, only made a call, failure immediately error. Usually used for non-idempotent write operations,
// such as adding records.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// NewFailFastCluster returns a failfast cluster instance.
//
// Fast failure, only made a call, failure immediately error. Usually used for non-idempotent write operations,
// such as adding records.

func NewFailFastCluster() cluster.Cluster {
return &failfastCluster{}
}
Expand Down
6 changes: 5 additions & 1 deletion cluster/cluster_impl/failover_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ func init() {
extension.SetCluster(name, NewFailoverCluster)
}

// NewFailoverCluster ...
// NewFailoverCluster returns a failover cluster instance
//
// Failure automatically switch, when there is a failure,
// retry the other server (default). Usually used for read operations,
// but retries can result in longer delays.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// NewFailoverCluster returns a failover cluster instance.
//
// Failure automatically switch, when there is a failure,
// retry the other server (default). Usually used for read operations,
// but retries can result in longer delays.

func NewFailoverCluster() cluster.Cluster {
return &failoverCluster{}
}
Expand Down
5 changes: 4 additions & 1 deletion cluster/cluster_impl/failsafe_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ func init() {
extension.SetCluster(failsafe, NewFailsafeCluster)
}

// NewFailsafeCluster ...
// NewFailsafeCluster returns a failsafe cluster instance.
//
// Failure of security, anomalies, directly ignored. Usually it is
// used to write audit logs and other operations.
func NewFailsafeCluster() cluster.Cluster {
return &failsafeCluster{}
}
Expand Down
5 changes: 4 additions & 1 deletion cluster/cluster_impl/forking_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ func init() {
extension.SetCluster(forking, NewForkingCluster)
}

// NewForkingCluster ...
// NewForkingCluster returns a forking cluster instance.
//
// Multiple servers are invoked in parallel, returning as soon as one succeeds.
// Usually it is used for real-time demanding read operations while wasting more service resources.
func NewForkingCluster() cluster.Cluster {
return &forkingCluster{}
}
Expand Down
6 changes: 5 additions & 1 deletion cluster/cluster_impl/mock_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ import (

type mockCluster struct{}

// NewMockCluster ...
// NewMockCluster returns a mock cluster instance.
//
// Mock cluster is usually used for service degradation, such as an authentication service.
// When the service provider is completely hung up, the client does not throw an exception,
// return an authorization failure through the Mock data instead.
func NewMockCluster() cluster.Cluster {
return &mockCluster{}
}
Expand Down
2 changes: 1 addition & 1 deletion cluster/cluster_impl/registry_aware_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func init() {
extension.SetCluster("registryAware", NewRegistryAwareCluster)
}

// NewRegistryAwareCluster ...
// NewRegistryAwareCluster returns a registry aware cluster instance
func NewRegistryAwareCluster() cluster.Cluster {
return &registryAwareCluster{}
}
Expand Down
2 changes: 1 addition & 1 deletion cluster/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
)

// Directory
//Extension - Directory
// Extension - Directory
type Directory interface {
common.Node
List(invocation protocol.Invocation) []protocol.Invoker
Expand Down
2 changes: 1 addition & 1 deletion cluster/loadbalance.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
)

// LoadBalance
//Extension - LoadBalance
// Extension - LoadBalance
type LoadBalance interface {
Select([]protocol.Invoker, protocol.Invocation) protocol.Invoker
}
2 changes: 2 additions & 0 deletions cluster/loadbalance/consistent_hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ type ConsistentHashLoadBalance struct {
}

// NewConsistentHashLoadBalance creates NewConsistentHashLoadBalance
//
// The same parameters of the request is always sent to the same provider.
func NewConsistentHashLoadBalance() cluster.LoadBalance {
return &ConsistentHashLoadBalance{}
}
Expand Down
6 changes: 4 additions & 2 deletions cluster/loadbalance/least_active.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

const (
// LeastActive ...
// LeastActive is used to set the load balance extension
LeastActive = "leastactive"
zouyx marked this conversation as resolved.
Show resolved Hide resolved
)

Expand All @@ -39,7 +39,9 @@ func init() {
type leastActiveLoadBalance struct {
}

// NewLeastActiveLoadBalance ...
// NewLeastActiveLoadBalance returns a least active load balance.
//
// A random mechanism based on actives, actives means the number of a consumer's requests have been sent to provider but not yet got response.
func NewLeastActiveLoadBalance() cluster.LoadBalance {
return &leastActiveLoadBalance{}
}
Expand Down
4 changes: 3 additions & 1 deletion cluster/loadbalance/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ func init() {
type randomLoadBalance struct {
}

// NewRandomLoadBalance ...
// NewRandomLoadBalance returns a random load balance instance.
//
// Set random probabilities by weight, and the request will be sent to provider randomly.
func NewRandomLoadBalance() cluster.LoadBalance {
return &randomLoadBalance{}
}
Expand Down
4 changes: 3 additions & 1 deletion cluster/loadbalance/round_robin.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ func init() {

type roundRobinLoadBalance struct{}

// NewRoundRobinLoadBalance ...
// NewRoundRobinLoadBalance returns a round robin load balance
//
// Use the weight's common advisory to determine round robin ratio
func NewRoundRobinLoadBalance() cluster.LoadBalance {
return &roundRobinLoadBalance{}
}
Expand Down
2 changes: 1 addition & 1 deletion cluster/loadbalance/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/apache/dubbo-go/protocol"
)

// GetWeight ...
// GetWeight gets weight for load balance strategy
func GetWeight(invoker protocol.Invoker, invocation protocol.Invocation) int64 {
url := invoker.GetUrl()
weight := url.GetMethodParamInt64(invocation.MethodName(), constant.WEIGHT_KEY, constant.DEFAULT_WEIGHT)
Expand Down