mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
29 lines
402 B
Go
29 lines
402 B
Go
package discoveryregistry
|
|
|
|
import "google.golang.org/grpc"
|
|
|
|
type Robin struct {
|
|
next int
|
|
}
|
|
|
|
func (r *Robin) Robin(slice []*grpc.ClientConn) int {
|
|
index := r.next
|
|
r.next += 1
|
|
if r.next > len(slice)-1 {
|
|
r.next = 0
|
|
}
|
|
return index
|
|
}
|
|
|
|
type Hash struct {
|
|
}
|
|
|
|
func (r *Hash) Hash(slice []*grpc.ClientConn) int {
|
|
index := r.next
|
|
r.next += 1
|
|
if r.next > len(slice)-1 {
|
|
r.next = 0
|
|
}
|
|
return index
|
|
}
|