golang 哈希负载均衡
代码记录
#package main
import (
“fmt”
“hash/crc32”
“day1/example3/balance”
“math/rand”
)
type HashBalance struct {
}
func init() {
balance.RegisterBalancer(“hash”, &HashBalance{})
}
func (p *HashBalance) DoBalance(insts []*balance.Instance, key…string) (inst *balance.Instance, err error) {
var defKey string = fmt.Sprintf("%d", rand.Int())
}