Skip to content

Load balancing interface implementation library, which implements some common load balancing algorithms, 负载均衡:随机、轮询、权重、哈希

License

Notifications You must be signed in to change notification settings

wanglong001/balancer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Balancer

Load balancing interface implementation library, which implements some common load balancing algorithms

  • RoundRobinBalancer
  • WeightBalancer
  • LeastResourcesBalancer
  • HashBalancer
  • ....

Example

ipList := []string{"0.0.0.0", "0.0.0.1", "0.0.0.2", "0.0.0.3", "0.0.0.4", "0.0.0.5"}
s := make([]interface{}, len(ipList))
for i, v := range ipList {
    s[i] = v
}
rb := &RoundRobinBalancer{offset: 0, partitions: []interface{}(s)}
for i := 0; i < 50; i++ {
    y := rb.Balance()  // gen 
}

refer: https://github.com/segmentio/kafka-go/blob/master/balancer.go

About

Load balancing interface implementation library, which implements some common load balancing algorithms, 负载均衡:随机、轮询、权重、哈希

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages