зеркало из https://github.com/github/vitess-gh.git
Add server and client support for application errors in RPC response for VTGate.SplitQuery
This commit is contained in:
Родитель
dff0dc634a
Коммит
4216b97d40
|
@ -322,6 +322,9 @@ func (conn *vtgateConn) SplitQuery(ctx context.Context, keyspace string, query t
|
|||
if err := conn.rpcConn.Call(ctx, "VTGate.SplitQuery", request, result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := vterrors.FromRPCError(result.Err); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.Splits, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -181,7 +181,12 @@ func (vtg *VTGate) SplitQuery(ctx context.Context, req *proto.SplitQueryRequest,
|
|||
defer vtg.server.HandlePanic(&err)
|
||||
ctx, cancel := context.WithDeadline(ctx, time.Now().Add(*rpcTimeout))
|
||||
defer cancel()
|
||||
return vtg.server.SplitQuery(ctx, req, reply)
|
||||
vtgErr := vtg.server.SplitQuery(ctx, req, reply)
|
||||
vtgate.AddVtGateErrorToSplitQueryResult(vtgErr, reply)
|
||||
if *vtgate.RPCErrorOnlyInReply {
|
||||
return nil
|
||||
}
|
||||
return vtgErr
|
||||
}
|
||||
|
||||
// New returns a new VTGate service
|
||||
|
|
|
@ -178,4 +178,5 @@ type SplitQueryPart struct {
|
|||
// SplitQueryResult is the result for SplitQueryRequest
|
||||
type SplitQueryResult struct {
|
||||
Splits []SplitQueryPart
|
||||
Err *mproto.RPCError
|
||||
}
|
||||
|
|
|
@ -41,3 +41,12 @@ func AddVtGateErrorToQueryResultList(err error, reply *proto.QueryResultList) {
|
|||
}
|
||||
reply.Err = rpcErrFromVtGateError(err)
|
||||
}
|
||||
|
||||
// AddVtGateErrorToSplitQueryResult will mutate a SplitQueryResult struct to fill in the Err
|
||||
// field with details from the VTGate error.
|
||||
func AddVtGateErrorToSplitQueryResult(err error, reply *proto.SplitQueryResult) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
reply.Err = rpcErrFromVtGateError(err)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче