balancer: add rpc method to PickOptions (#2204)
Provide additional context to Pickers that wish to make decisions based on the RPC method. Relevant issue: https://github.com/grpc/grpc-go/issues/2103
This commit is contained in:
@ -143,7 +143,11 @@ type Builder interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PickOptions contains addition information for the Pick operation.
|
// PickOptions contains addition information for the Pick operation.
|
||||||
type PickOptions struct{}
|
type PickOptions struct {
|
||||||
|
// FullMethodName is the method name that NewClientStream() is called
|
||||||
|
// with. The canonical format is /service/Method.
|
||||||
|
FullMethodName string
|
||||||
|
}
|
||||||
|
|
||||||
// DoneInfo contains additional information for done.
|
// DoneInfo contains additional information for done.
|
||||||
type DoneInfo struct {
|
type DoneInfo struct {
|
||||||
|
@ -1059,8 +1059,10 @@ func (cc *ClientConn) GetMethodConfig(method string) MethodConfig {
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *ClientConn) getTransport(ctx context.Context, failfast bool) (transport.ClientTransport, func(balancer.DoneInfo), error) {
|
func (cc *ClientConn) getTransport(ctx context.Context, failfast bool, method string) (transport.ClientTransport, func(balancer.DoneInfo), error) {
|
||||||
t, done, err := cc.blockingpicker.pick(ctx, failfast, balancer.PickOptions{})
|
t, done, err := cc.blockingpicker.pick(ctx, failfast, balancer.PickOptions{
|
||||||
|
FullMethodName: method,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, toRPCErr(err)
|
return nil, nil, toRPCErr(err)
|
||||||
}
|
}
|
||||||
|
@ -311,7 +311,7 @@ func (cs *clientStream) newAttemptLocked(sh stats.Handler, trInfo traceInfo) err
|
|||||||
if err := cs.ctx.Err(); err != nil {
|
if err := cs.ctx.Err(); err != nil {
|
||||||
return toRPCErr(err)
|
return toRPCErr(err)
|
||||||
}
|
}
|
||||||
t, done, err := cs.cc.getTransport(cs.ctx, cs.callInfo.failFast)
|
t, done, err := cs.cc.getTransport(cs.ctx, cs.callInfo.failFast, cs.callHdr.Method)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user