本文整理汇总了Golang中github.com/youtube/vitess/go/vt/vtgate.AddVtGateErrorToQueryResult函数的典型用法代码示例。如果您正苦于以下问题:Golang AddVtGateErrorToQueryResult函数的具体用法?Golang AddVtGateErrorToQueryResult怎么用?Golang AddVtGateErrorToQueryResult使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AddVtGateErrorToQueryResult函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: StreamExecuteKeyRanges2
// StreamExecuteKeyRanges2 is the RPC version of
// vtgateservice.VTGateService method
func (vtg *VTGate) StreamExecuteKeyRanges2(ctx context.Context, request *proto.KeyRangeQuery, sendReply func(interface{}) error) (err error) {
defer vtg.server.HandlePanic(&err)
ctx = callerid.NewContext(ctx,
callerid.GoRPCEffectiveCallerID(request.CallerID),
callerid.NewImmediateCallerID("gorpc client"))
vtgErr := vtg.server.StreamExecuteKeyRanges(ctx,
request.Sql,
request.BindVariables,
request.Keyspace,
key.KeyRangesToProto(request.KeyRanges),
topo.TabletTypeToProto(request.TabletType),
func(value *proto.QueryResult) error {
return sendReply(value)
})
if vtgErr == nil {
return nil
}
if *vtgate.RPCErrorOnlyInReply {
// If there was an app error, send a QueryResult back with it.
qr := new(proto.QueryResult)
vtgate.AddVtGateErrorToQueryResult(vtgErr, qr)
// Sending back errors this way is not backwards compatible. If a (new) server sends an additional
// QueryResult with an error, and the (old) client doesn't know how to read it, it will cause
// problems where the client will get out of sync with the number of QueryResults sent.
// That's why this the error is only sent this way when the --rpc_errors_only_in_reply flag is set
// (signalling that all clients are able to handle new-style errors).
return sendReply(qr)
}
return vtgErr
}
示例2: ExecuteEntityIds
// ExecuteEntityIds is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGate) ExecuteEntityIds(ctx context.Context, query *proto.EntityIdsQuery, reply *proto.QueryResult) (err error) {
defer vtg.server.HandlePanic(&err)
ctx, cancel := context.WithDeadline(ctx, time.Now().Add(*rpcTimeout))
defer cancel()
vtgErr := vtg.server.ExecuteEntityIds(ctx, query, reply)
vtgate.AddVtGateErrorToQueryResult(vtgErr, reply)
if *vtgate.RPCErrorOnlyInReply {
return nil
}
return vtgErr
}
示例3: ExecuteEntityIds
// ExecuteEntityIds is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGate) ExecuteEntityIds(ctx context.Context, request *proto.EntityIdsQuery, reply *proto.QueryResult) (err error) {
defer vtg.server.HandlePanic(&err)
ctx, cancel := context.WithDeadline(ctx, time.Now().Add(*rpcTimeout))
defer cancel()
ctx = callerid.NewContext(ctx,
callerid.GoRPCEffectiveCallerID(request.CallerID),
callerid.NewImmediateCallerID("gorpc client"))
vtgErr := vtg.server.ExecuteEntityIds(ctx, request, reply)
vtgate.AddVtGateErrorToQueryResult(vtgErr, reply)
if *vtgate.RPCErrorOnlyInReply {
return nil
}
return vtgErr
}
示例4: Execute
// Execute is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGate) Execute(ctx context.Context, request *proto.Query, reply *proto.QueryResult) (err error) {
defer vtg.server.HandlePanic(&err)
ctx, cancel := context.WithDeadline(ctx, time.Now().Add(*rpcTimeout))
defer cancel()
ctx = callerid.NewContext(ctx,
callerid.GoRPCEffectiveCallerID(request.CallerID),
callerid.NewImmediateCallerID("gorpc client"))
vtgErr := vtg.server.Execute(ctx,
request.Sql,
request.BindVariables,
topo.TabletTypeToProto(request.TabletType),
request.Session,
request.NotInTransaction,
reply)
vtgate.AddVtGateErrorToQueryResult(vtgErr, reply)
if *vtgate.RPCErrorOnlyInReply {
return nil
}
return vtgErr
}