2020-07-30 20:09:45 +08:00
|
|
|
package balancer
|
|
|
|
|
|
|
|
import (
|
2020-07-30 22:56:13 +08:00
|
|
|
"context"
|
|
|
|
|
2020-07-30 20:09:45 +08:00
|
|
|
"google.golang.org/grpc/balancer"
|
|
|
|
"google.golang.org/grpc/balancer/base"
|
2020-07-30 22:56:13 +08:00
|
|
|
"google.golang.org/grpc/resolver"
|
2020-07-30 20:09:45 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
Name = "roundrobin"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
balancer.Register(newBuilder())
|
|
|
|
}
|
|
|
|
|
|
|
|
type roundRobinPickerBuilder struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func newBuilder() balancer.Builder {
|
|
|
|
return base.NewBalancerBuilder(Name, new(roundRobinPickerBuilder))
|
|
|
|
}
|
|
|
|
|
2020-07-30 22:56:13 +08:00
|
|
|
func (b *roundRobinPickerBuilder) Build(readySCs map[resolver.Address]balancer.SubConn) balancer.Picker {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
type roundRobinPicker struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *roundRobinPicker) Pick(ctx context.Context, info balancer.PickInfo) (
|
|
|
|
conn balancer.SubConn, done func(balancer.DoneInfo), err error) {
|
2020-07-30 20:09:45 +08:00
|
|
|
panic("implement me")
|
|
|
|
}
|