Add dial option to set balancer (#1697)

WithBalancerName dial option specifies the name of the balancer to be used by the ClientConn. Service config updates can NOT override the balancer option.
This commit is contained in:
Menghan Li
2017-12-18 15:35:42 -08:00
committed by GitHub
parent 6610f9a340
commit e6549e636d
10 changed files with 110 additions and 45 deletions

View File

@ -26,7 +26,8 @@ import (
"google.golang.org/grpc/resolver"
)
const pickfirstName = "pick_first"
// PickFirstBalancerName is the name of the pick_first balancer.
const PickFirstBalancerName = "pick_first"
func newPickfirstBuilder() balancer.Builder {
return &pickfirstBuilder{}
@ -39,7 +40,7 @@ func (*pickfirstBuilder) Build(cc balancer.ClientConn, opt balancer.BuildOptions
}
func (*pickfirstBuilder) Name() string {
return pickfirstName
return PickFirstBalancerName
}
type pickfirstBalancer struct {