зеркало из https://github.com/github/vitess-gh.git
Simplify AddTabletError functions
This commit is contained in:
Родитель
f1602aa468
Коммит
f7029a76de
|
@ -29,7 +29,7 @@ type SqlQuery struct {
|
|||
func (sq *SqlQuery) GetSessionId(sessionParams *proto.SessionParams, sessionInfo *proto.SessionInfo) (err error) {
|
||||
defer sq.server.HandlePanic(&err)
|
||||
tErr := sq.server.GetSessionId(sessionParams, sessionInfo)
|
||||
tabletserver.AddTabletErrorToSessionInfo(tErr, sessionInfo)
|
||||
tabletserver.AddTabletError(tErr, &sessionInfo.Err)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ func (sq *SqlQuery) GetSessionId(sessionParams *proto.SessionParams, sessionInfo
|
|||
func (sq *SqlQuery) GetSessionId2(sessionIdReq *proto.GetSessionIdRequest, sessionInfo *proto.SessionInfo) (err error) {
|
||||
defer sq.server.HandlePanic(&err)
|
||||
tErr := sq.server.GetSessionId(&sessionIdReq.Params, sessionInfo)
|
||||
tabletserver.AddTabletErrorToSessionInfo(tErr, sessionInfo)
|
||||
tabletserver.AddTabletError(tErr, &sessionInfo.Err)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ func (sq *SqlQuery) GetSessionId2(sessionIdReq *proto.GetSessionIdRequest, sessi
|
|||
func (sq *SqlQuery) Begin(ctx context.Context, session *proto.Session, txInfo *proto.TransactionInfo) (err error) {
|
||||
defer sq.server.HandlePanic(&err)
|
||||
tErr := sq.server.Begin(callinfo.RPCWrapCallInfo(ctx), nil, session, txInfo)
|
||||
tabletserver.AddTabletErrorToTransactionInfo(tErr, txInfo)
|
||||
tabletserver.AddTabletError(tErr, &txInfo.Err)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ func (sq *SqlQuery) Begin2(ctx context.Context, beginRequest *proto.BeginRequest
|
|||
tErr := sq.server.Begin(callinfo.RPCWrapCallInfo(ctx), proto.TargetToProto3(beginRequest.Target), session, txInfo)
|
||||
// Convert from TxInfo => beginResponse for the output
|
||||
beginResponse.TransactionId = txInfo.TransactionId
|
||||
tabletserver.AddTabletErrorToBeginResponse(tErr, beginResponse)
|
||||
tabletserver.AddTabletError(tErr, &beginResponse.Err)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ func (sq *SqlQuery) Commit2(ctx context.Context, commitRequest *proto.CommitRequ
|
|||
callerid.GoRPCImmediateCallerID(commitRequest.ImmediateCallerID),
|
||||
)
|
||||
tErr := sq.server.Commit(callinfo.RPCWrapCallInfo(ctx), proto.TargetToProto3(commitRequest.Target), session)
|
||||
tabletserver.AddTabletErrorToCommitResponse(tErr, commitResponse)
|
||||
tabletserver.AddTabletError(tErr, &commitResponse.Err)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ func (sq *SqlQuery) Rollback2(ctx context.Context, rollbackRequest *proto.Rollba
|
|||
callerid.GoRPCImmediateCallerID(rollbackRequest.ImmediateCallerID),
|
||||
)
|
||||
tErr := sq.server.Rollback(callinfo.RPCWrapCallInfo(ctx), proto.TargetToProto3(rollbackRequest.Target), session)
|
||||
tabletserver.AddTabletErrorToRollbackResponse(tErr, rollbackResponse)
|
||||
tabletserver.AddTabletError(tErr, &rollbackResponse.Err)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ func (sq *SqlQuery) Rollback2(ctx context.Context, rollbackRequest *proto.Rollba
|
|||
func (sq *SqlQuery) Execute(ctx context.Context, query *proto.Query, reply *mproto.QueryResult) (err error) {
|
||||
defer sq.server.HandlePanic(&err)
|
||||
tErr := sq.server.Execute(callinfo.RPCWrapCallInfo(ctx), nil, query, reply)
|
||||
tabletserver.AddTabletErrorToQueryResult(tErr, reply)
|
||||
tabletserver.AddTabletError(tErr, &reply.Err)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ func (sq *SqlQuery) Execute2(ctx context.Context, executeRequest *proto.ExecuteR
|
|||
callerid.GoRPCImmediateCallerID(executeRequest.ImmediateCallerID),
|
||||
)
|
||||
tErr := sq.server.Execute(callinfo.RPCWrapCallInfo(ctx), proto.TargetToProto3(executeRequest.Target), &executeRequest.QueryRequest, reply)
|
||||
tabletserver.AddTabletErrorToQueryResult(tErr, reply)
|
||||
tabletserver.AddTabletError(tErr, &reply.Err)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ func (sq *SqlQuery) StreamExecute2(ctx context.Context, req *proto.StreamExecute
|
|||
}
|
||||
// If there was an app error, send a QueryResult back with it.
|
||||
qr := new(mproto.QueryResult)
|
||||
tabletserver.AddTabletErrorToQueryResult(tErr, qr)
|
||||
tabletserver.AddTabletError(tErr, &qr.Err)
|
||||
return sendReply(qr)
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ func (sq *SqlQuery) StreamExecute2(ctx context.Context, req *proto.StreamExecute
|
|||
func (sq *SqlQuery) ExecuteBatch(ctx context.Context, queryList *proto.QueryList, reply *proto.QueryResultList) (err error) {
|
||||
defer sq.server.HandlePanic(&err)
|
||||
tErr := sq.server.ExecuteBatch(callinfo.RPCWrapCallInfo(ctx), nil, queryList, reply)
|
||||
tabletserver.AddTabletErrorToQueryResultList(tErr, reply)
|
||||
tabletserver.AddTabletError(tErr, &reply.Err)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ func (sq *SqlQuery) ExecuteBatch2(ctx context.Context, req *proto.ExecuteBatchRe
|
|||
callerid.GoRPCImmediateCallerID(req.ImmediateCallerID),
|
||||
)
|
||||
tErr := sq.server.ExecuteBatch(callinfo.RPCWrapCallInfo(ctx), proto.TargetToProto3(req.Target), &req.QueryBatch, reply)
|
||||
tabletserver.AddTabletErrorToQueryResultList(tErr, reply)
|
||||
tabletserver.AddTabletError(tErr, &reply.Err)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ func (sq *SqlQuery) SplitQuery(ctx context.Context, req *proto.SplitQueryRequest
|
|||
callerid.GoRPCImmediateCallerID(req.ImmediateCallerID),
|
||||
)
|
||||
tErr := sq.server.SplitQuery(callinfo.RPCWrapCallInfo(ctx), proto.TargetToProto3(req.Target), req, reply)
|
||||
tabletserver.AddTabletErrorToSplitQueryResult(tErr, reply)
|
||||
tabletserver.AddTabletError(tErr, &reply.Err)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ import (
|
|||
"github.com/youtube/vitess/go/tb"
|
||||
"github.com/youtube/vitess/go/vt/logutil"
|
||||
"github.com/youtube/vitess/go/vt/proto/vtrpc"
|
||||
"github.com/youtube/vitess/go/vt/tabletserver/proto"
|
||||
"github.com/youtube/vitess/go/vt/vterrors"
|
||||
)
|
||||
|
||||
|
@ -301,74 +300,10 @@ func rpcErrFromTabletError(err error) *mproto.RPCError {
|
|||
}
|
||||
}
|
||||
|
||||
// AddTabletErrorToQueryResult will mutate a QueryResult struct to fill in the Err
|
||||
// field with details from the TabletError.
|
||||
func AddTabletErrorToQueryResult(err error, reply *mproto.QueryResult) {
|
||||
// AddTabletError will update a mproto.RPCError with details from a TabletError.
|
||||
func AddTabletError(err error, replyErr **mproto.RPCError) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
reply.Err = rpcErrFromTabletError(err)
|
||||
}
|
||||
|
||||
// AddTabletErrorToSessionInfo will mutate a SessionInfo struct to fill in the Err
|
||||
// field with details from the TabletError.
|
||||
func AddTabletErrorToSessionInfo(err error, reply *proto.SessionInfo) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
reply.Err = rpcErrFromTabletError(err)
|
||||
}
|
||||
|
||||
// AddTabletErrorToTransactionInfo will mutate a TransactionInfo struct to fill in the Err
|
||||
// field with details from the TabletError.
|
||||
func AddTabletErrorToTransactionInfo(err error, reply *proto.TransactionInfo) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
reply.Err = rpcErrFromTabletError(err)
|
||||
}
|
||||
|
||||
// AddTabletErrorToQueryResultList will mutate a QueryResultList struct to fill in the Err
|
||||
// field with details from the TabletError.
|
||||
func AddTabletErrorToQueryResultList(err error, reply *proto.QueryResultList) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
reply.Err = rpcErrFromTabletError(err)
|
||||
}
|
||||
|
||||
// AddTabletErrorToSplitQueryResult will mutate a SplitQueryResult struct to fill in the Err
|
||||
// field with details from the TabletError.
|
||||
func AddTabletErrorToSplitQueryResult(err error, reply *proto.SplitQueryResult) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
reply.Err = rpcErrFromTabletError(err)
|
||||
}
|
||||
|
||||
// AddTabletErrorToBeginResponse will mutate a BeginResponse struct to fill in the Err
|
||||
// field with details from the TabletError.
|
||||
func AddTabletErrorToBeginResponse(err error, reply *proto.BeginResponse) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
reply.Err = rpcErrFromTabletError(err)
|
||||
}
|
||||
|
||||
// AddTabletErrorToCommitResponse will mutate a CommitResponse struct to fill in the Err
|
||||
// field with details from the TabletError.
|
||||
func AddTabletErrorToCommitResponse(err error, reply *proto.CommitResponse) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
reply.Err = rpcErrFromTabletError(err)
|
||||
}
|
||||
|
||||
// AddTabletErrorToRollbackResponse will mutate a RollbackResponse struct to fill in the Err
|
||||
// field with details from the TabletError.
|
||||
func AddTabletErrorToRollbackResponse(err error, reply *proto.RollbackResponse) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
reply.Err = rpcErrFromTabletError(err)
|
||||
*replyErr = rpcErrFromTabletError(err)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче