Documentation ¶
Index ¶
- Constants
- func GetWeight(invoker protocol.Invoker, invocation protocol.Invocation) int64
- func NewConsistentHashLoadBalance() cluster.LoadBalance
- func NewLeastActiveLoadBalance() cluster.LoadBalance
- func NewRandomLoadBalance() cluster.LoadBalance
- func NewRoundRobinLoadBalance() cluster.LoadBalance
- type ConsistentHashLoadBalance
Constants ¶
const ( // ConsistentHash consistent hash ConsistentHash = "consistenthash" // HashNodes hash nodes HashNodes = "hash.nodes" // HashArguments key of hash arguments in url HashArguments = "hash.arguments" )
const ( // RoundRobin load balancing way RoundRobin = "roundrobin" // nolint COMPLETE = 0 // nolint UPDATING = 1 )
const (
// LeastActive is used to set the load balance extension
LeastActive = "leastactive"
)
Variables ¶
This section is empty.
Functions ¶
func GetWeight ¶
func GetWeight(invoker protocol.Invoker, invocation protocol.Invocation) int64
GetWeight gets weight for load balance strategy
func NewConsistentHashLoadBalance ¶ added in v1.3.0
func NewConsistentHashLoadBalance() cluster.LoadBalance
NewConsistentHashLoadBalance creates NewConsistentHashLoadBalance
The same parameters of the request is always sent to the same provider.
func NewLeastActiveLoadBalance ¶
func NewLeastActiveLoadBalance() cluster.LoadBalance
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 NewRandomLoadBalance ¶
func NewRandomLoadBalance() cluster.LoadBalance
NewRandomLoadBalance returns a random load balance instance.
Set random probabilities by weight, and the request will be sent to provider randomly.
func NewRoundRobinLoadBalance ¶
func NewRoundRobinLoadBalance() cluster.LoadBalance
NewRoundRobinLoadBalance returns a round robin load balance
Use the weight's common advisory to determine round robin ratio
Types ¶
type ConsistentHashLoadBalance ¶ added in v1.3.0
type ConsistentHashLoadBalance struct { }
ConsistentHashLoadBalance implementation of load balancing: using consistent hashing
func (*ConsistentHashLoadBalance) Select ¶ added in v1.3.0
func (lb *ConsistentHashLoadBalance) Select(invokers []protocol.Invoker, invocation protocol.Invocation) protocol.Invoker
Select gets invoker based on load balancing strategy