本文整理汇总了Golang中github.com/youtube/vitess/go/vt/tabletserver.ToGRPCError函数的典型用法代码示例。如果您正苦于以下问题:Golang ToGRPCError函数的具体用法?Golang ToGRPCError怎么用?Golang ToGRPCError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ToGRPCError函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ExecuteBatch
// ExecuteBatch is part of the queryservice.QueryServer interface
func (q *query) ExecuteBatch(ctx context.Context, request *pb.ExecuteBatchRequest) (response *pb.ExecuteBatchResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
reply := new(proto.QueryResultList)
bql, err := proto.Proto3ToBoundQueryList(request.Queries)
if err != nil {
return nil, tabletserver.ToGRPCError(err)
}
if err := q.server.ExecuteBatch(ctx, request.Target, &proto.QueryList{
Queries: bql,
SessionId: request.SessionId,
AsTransaction: request.AsTransaction,
TransactionId: request.TransactionId,
}, reply); err != nil {
return nil, tabletserver.ToGRPCError(err)
}
results, err := proto.QueryResultListToProto3(reply.List)
if err != nil {
return nil, tabletserver.ToGRPCError(err)
}
return &pb.ExecuteBatchResponse{Results: results}, nil
}
开发者ID:khanchan,项目名称:vitess,代码行数:26,代码来源:server.go
示例2: SplitQuery
// SplitQuery is part of the queryservice.QueryServer interface
func (q *query) SplitQuery(ctx context.Context, request *pb.SplitQueryRequest) (response *pb.SplitQueryResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
reply := &proto.SplitQueryResult{}
bq, err := proto.Proto3ToBoundQuery(request.Query)
if err != nil {
return nil, tabletserver.ToGRPCError(err)
}
if err := q.server.SplitQuery(ctx, request.Target, &proto.SplitQueryRequest{
Query: *bq,
SplitColumn: request.SplitColumn,
SplitCount: int(request.SplitCount),
SessionID: request.SessionId,
}, reply); err != nil {
return nil, tabletserver.ToGRPCError(err)
}
qs, err := proto.QuerySplitsToProto3(reply.Queries)
if err != nil {
return nil, tabletserver.ToGRPCError(err)
}
return &pb.SplitQueryResponse{Queries: qs}, nil
}
开发者ID:hadmagic,项目名称:vitess,代码行数:26,代码来源:server.go
示例3: Execute
// Execute is part of the queryservice.QueryServer interface
func (q *query) Execute(ctx context.Context, request *pb.ExecuteRequest) (response *pb.ExecuteResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
reply := new(mproto.QueryResult)
bv, err := proto.Proto3ToBindVariables(request.Query.BindVariables)
if err != nil {
return nil, tabletserver.ToGRPCError(err)
}
if err := q.server.Execute(ctx, request.Target, &proto.Query{
Sql: request.Query.Sql,
BindVariables: bv,
SessionId: request.SessionId,
TransactionId: request.TransactionId,
}, reply); err != nil {
return nil, tabletserver.ToGRPCError(err)
}
result, err := mproto.QueryResultToProto3(reply)
if err != nil {
return nil, tabletserver.ToGRPCError(err)
}
return &pb.ExecuteResponse{Result: result}, nil
}
开发者ID:khanchan,项目名称:vitess,代码行数:26,代码来源:server.go
示例4: StreamExecute
// StreamExecute is part of the queryservice.QueryServer interface
func (q *query) StreamExecute(request *pb.StreamExecuteRequest, stream pbs.Query_StreamExecuteServer) (err error) {
defer q.server.HandlePanic(&err)
ctx := callerid.NewContext(callinfo.GRPCCallInfo(stream.Context()),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
bv, err := proto.Proto3ToBindVariables(request.Query.BindVariables)
if err != nil {
return tabletserver.ToGRPCError(err)
}
if err := q.server.StreamExecute(ctx, request.Target, &proto.Query{
Sql: request.Query.Sql,
BindVariables: bv,
SessionId: request.SessionId,
}, func(reply *mproto.QueryResult) error {
result, err := mproto.QueryResultToProto3(reply)
if err != nil {
return err
}
return stream.Send(&pb.StreamExecuteResponse{Result: result})
}); err != nil {
return tabletserver.ToGRPCError(err)
}
return nil
}
开发者ID:khanchan,项目名称:vitess,代码行数:26,代码来源:server.go
示例5: ExecuteBatch
// ExecuteBatch is part of tabletconn.TabletConn
// We need to copy the bind variables as tablet server will change them.
func (itc *internalTabletConn) ExecuteBatch(ctx context.Context, queries []tproto.BoundQuery, asTransaction bool, transactionID int64) (*tproto.QueryResultList, error) {
q := make([]tproto.BoundQuery, len(queries))
for i, query := range queries {
bv, err := tproto.BindVariablesToProto3(query.BindVariables)
if err != nil {
return nil, err
}
bindVars, err := tproto.Proto3ToBindVariables(bv)
if err != nil {
return nil, err
}
q[i].Sql = query.Sql
q[i].BindVariables = bindVars
}
reply := &tproto.QueryResultList{}
if err := itc.tablet.qsc.QueryService().ExecuteBatch(ctx, &querypb.Target{
Keyspace: itc.tablet.keyspace,
Shard: itc.tablet.shard,
TabletType: itc.tablet.tabletType,
}, &tproto.QueryList{
Queries: q,
AsTransaction: asTransaction,
TransactionId: transactionID,
}, reply); err != nil {
return nil, tabletconn.TabletErrorFromGRPC(tabletserver.ToGRPCError(err))
}
return reply, nil
}
开发者ID:zhangzzl,项目名称:vitess,代码行数:30,代码来源:tablet_map.go
示例6: StreamExecute
// StreamExecute is part of tabletconn.TabletConn
// We need to copy the bind variables as tablet server will change them.
func (itc *internalTabletConn) StreamExecute(ctx context.Context, query string, bindVars map[string]interface{}, transactionID int64) (<-chan *mproto.QueryResult, tabletconn.ErrFunc, error) {
bindVars = tproto.Proto3ToBindVariables(tproto.BindVariablesToProto3(bindVars))
result := make(chan *mproto.QueryResult, 10)
var finalErr error
go func() {
finalErr = itc.tablet.qsc.QueryService().StreamExecute(ctx, &pbq.Target{
Keyspace: itc.tablet.keyspace,
Shard: itc.tablet.shard,
TabletType: itc.tablet.tabletType,
}, &tproto.Query{
Sql: query,
BindVariables: bindVars,
TransactionId: transactionID,
}, func(reply *mproto.QueryResult) error {
result <- reply
return nil
})
// the client will only access finalErr after the
// channel is closed, and then it's already set.
close(result)
}()
return result, func() error {
return tabletconn.TabletErrorFromGRPC(tabletserver.ToGRPCError(finalErr))
}, nil
}
开发者ID:zhaoyta,项目名称:vitess,代码行数:30,代码来源:tablet_map.go
示例7: StreamExecute
// StreamExecute is part of tabletconn.TabletConn
// We need to copy the bind variables as tablet server will change them.
func (itc *internalTabletConn) StreamExecute(ctx context.Context, query string, bindVars map[string]interface{}, transactionID int64) (<-chan *sqltypes.Result, tabletconn.ErrFunc, error) {
bv, err := querytypes.BindVariablesToProto3(bindVars)
if err != nil {
return nil, nil, err
}
bindVars, err = querytypes.Proto3ToBindVariables(bv)
if err != nil {
return nil, nil, err
}
result := make(chan *sqltypes.Result, 10)
var finalErr error
go func() {
finalErr = itc.tablet.qsc.QueryService().StreamExecute(ctx, &querypb.Target{
Keyspace: itc.tablet.keyspace,
Shard: itc.tablet.shard,
TabletType: itc.tablet.tabletType,
}, query, bindVars, 0, func(reply *sqltypes.Result) error {
// We need to deep-copy the reply before returning,
// because the underlying buffers are reused.
result <- reply.Copy()
return nil
})
// the client will only access finalErr after the
// channel is closed, and then it's already set.
close(result)
}()
return result, func() error {
return tabletconn.TabletErrorFromGRPC(tabletserver.ToGRPCError(finalErr))
}, nil
}
开发者ID:littleyang,项目名称:vitess,代码行数:35,代码来源:tablet_map.go
示例8: StreamHealth
// StreamHealth is part of tabletconn.TabletConn
func (itc *internalTabletConn) StreamHealth(ctx context.Context) (tabletconn.StreamHealthReader, error) {
result := make(chan *querypb.StreamHealthResponse, 10)
id, err := itc.tablet.qsc.QueryService().StreamHealthRegister(result)
if err != nil {
return nil, err
}
var finalErr error
go func() {
select {
case <-ctx.Done():
}
// We populate finalErr before closing the channel.
// The consumer first waits on the channel closure,
// then read finalErr
finalErr = itc.tablet.qsc.QueryService().StreamHealthUnregister(id)
finalErr = tabletconn.TabletErrorFromGRPC(tabletserver.ToGRPCError(finalErr))
close(result)
}()
return &streamHealthReader{
c: result,
err: &finalErr,
}, nil
}
开发者ID:CowLeo,项目名称:vitess,代码行数:28,代码来源:tablet_map.go
示例9: SplitQueryV2
// SplitQueryV2 is part of tabletconn.TabletConn
// TODO(erez): Rename to SplitQuery once the migration to SplitQuery V2 is done.
func (itc *internalTabletConn) SplitQueryV2(
ctx context.Context,
query querytypes.BoundQuery,
splitColumns []string,
splitCount int64,
numRowsPerQueryPart int64,
algorithm querypb.SplitQueryRequest_Algorithm) ([]querytypes.QuerySplit, error) {
splits, err := itc.tablet.qsc.QueryService().SplitQueryV2(
ctx,
&querypb.Target{
Keyspace: itc.tablet.keyspace,
Shard: itc.tablet.shard,
TabletType: itc.tablet.tabletType,
},
query.Sql,
query.BindVariables,
splitColumns,
splitCount,
numRowsPerQueryPart,
algorithm)
if err != nil {
return nil, tabletconn.TabletErrorFromGRPC(tabletserver.ToGRPCError(err))
}
return splits, nil
}
开发者ID:CowLeo,项目名称:vitess,代码行数:28,代码来源:tablet_map.go
示例10: Rollback
// Rollback is part of tabletconn.TabletConn
func (itc *internalTabletConn) Rollback(ctx context.Context, transactionID int64) error {
err := itc.tablet.qsc.QueryService().Rollback(ctx, &querypb.Target{
Keyspace: itc.tablet.keyspace,
Shard: itc.tablet.shard,
TabletType: itc.tablet.tabletType,
}, 0, transactionID)
return tabletconn.TabletErrorFromGRPC(tabletserver.ToGRPCError(err))
}
开发者ID:littleyang,项目名称:vitess,代码行数:9,代码来源:tablet_map.go
示例11: ExecuteBatch
// ExecuteBatch is part of the queryservice.QueryServer interface
func (q *query) ExecuteBatch(ctx context.Context, request *querypb.ExecuteBatchRequest) (response *querypb.ExecuteBatchResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
bql, err := querytypes.Proto3ToBoundQueryList(request.Queries)
if err != nil {
return nil, tabletserver.ToGRPCError(err)
}
results, err := q.server.ExecuteBatch(ctx, request.Target, bql, request.SessionId, request.AsTransaction, request.TransactionId)
if err != nil {
return nil, tabletserver.ToGRPCError(err)
}
return &querypb.ExecuteBatchResponse{
Results: sqltypes.ResultsToProto3(results),
}, nil
}
开发者ID:littleyang,项目名称:vitess,代码行数:19,代码来源:server.go
示例12: Execute
// Execute is part of the queryservice.QueryServer interface
func (q *query) Execute(ctx context.Context, request *querypb.ExecuteRequest) (response *querypb.ExecuteResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
bv, err := querytypes.Proto3ToBindVariables(request.Query.BindVariables)
if err != nil {
return nil, tabletserver.ToGRPCError(err)
}
result, err := q.server.Execute(ctx, request.Target, request.Query.Sql, bv, request.SessionId, request.TransactionId)
if err != nil {
return nil, tabletserver.ToGRPCError(err)
}
return &querypb.ExecuteResponse{
Result: sqltypes.ResultToProto3(result),
}, nil
}
开发者ID:littleyang,项目名称:vitess,代码行数:19,代码来源:server.go
示例13: Commit
// Commit is part of tabletconn.TabletConn
func (itc *internalTabletConn) Commit(ctx context.Context, transactionID int64) error {
err := itc.tablet.qsc.QueryService().Commit(ctx, &pbq.Target{
Keyspace: itc.tablet.keyspace,
Shard: itc.tablet.shard,
TabletType: itc.tablet.tabletType,
}, &tproto.Session{
TransactionId: transactionID,
})
return tabletconn.TabletErrorFromGRPC(tabletserver.ToGRPCError(err))
}
开发者ID:zhaoyta,项目名称:vitess,代码行数:11,代码来源:tablet_map.go
示例14: StreamExecute
// StreamExecute is part of the queryservice.QueryServer interface
func (q *query) StreamExecute(request *querypb.StreamExecuteRequest, stream queryservicepb.Query_StreamExecuteServer) (err error) {
defer q.server.HandlePanic(&err)
ctx := callerid.NewContext(callinfo.GRPCCallInfo(stream.Context()),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
bv, err := querytypes.Proto3ToBindVariables(request.Query.BindVariables)
if err != nil {
return tabletserver.ToGRPCError(err)
}
if err := q.server.StreamExecute(ctx, request.Target, request.Query.Sql, bv, request.SessionId, func(reply *sqltypes.Result) error {
return stream.Send(&querypb.StreamExecuteResponse{
Result: sqltypes.ResultToProto3(reply),
})
}); err != nil {
return tabletserver.ToGRPCError(err)
}
return nil
}
开发者ID:littleyang,项目名称:vitess,代码行数:20,代码来源:server.go
示例15: Begin
// Begin is part of tabletconn.TabletConn
func (itc *internalTabletConn) Begin(ctx context.Context) (int64, error) {
transactionID, err := itc.tablet.qsc.QueryService().Begin(ctx, &querypb.Target{
Keyspace: itc.tablet.keyspace,
Shard: itc.tablet.shard,
TabletType: itc.tablet.tabletType,
}, 0)
if err != nil {
return 0, tabletconn.TabletErrorFromGRPC(tabletserver.ToGRPCError(err))
}
return transactionID, nil
}
开发者ID:littleyang,项目名称:vitess,代码行数:12,代码来源:tablet_map.go
示例16: Begin
// Begin is part of tabletconn.TabletConn
func (itc *internalTabletConn) Begin(ctx context.Context) (transactionID int64, err error) {
result := &tproto.TransactionInfo{}
if err := itc.tablet.qsc.QueryService().Begin(ctx, &pbq.Target{
Keyspace: itc.tablet.keyspace,
Shard: itc.tablet.shard,
TabletType: itc.tablet.tabletType,
}, &tproto.Session{}, result); err != nil {
return 0, tabletconn.TabletErrorFromGRPC(tabletserver.ToGRPCError(err))
}
return result.TransactionId, nil
}
开发者ID:zhaoyta,项目名称:vitess,代码行数:12,代码来源:tablet_map.go
示例17: Commit
// Commit is part of the queryservice.QueryServer interface
func (q *query) Commit(ctx context.Context, request *querypb.CommitRequest) (response *querypb.CommitResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
if err := q.server.Commit(ctx, request.Target, request.SessionId, request.TransactionId); err != nil {
return nil, tabletserver.ToGRPCError(err)
}
return &querypb.CommitResponse{}, nil
}
开发者ID:littleyang,项目名称:vitess,代码行数:12,代码来源:server.go
示例18: SplitQuery
// SplitQuery is part of the queryservice.QueryServer interface
func (q *query) SplitQuery(ctx context.Context, request *querypb.SplitQueryRequest) (response *querypb.SplitQueryResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
bq, err := querytypes.Proto3ToBoundQuery(request.Query)
if err != nil {
return nil, tabletserver.ToGRPCError(err)
}
splits, err := q.server.SplitQuery(ctx, request.Target, bq.Sql, bq.BindVariables, request.SplitColumn, request.SplitCount, request.SessionId)
if err != nil {
return nil, tabletserver.ToGRPCError(err)
}
qs, err := querytypes.QuerySplitsToProto3(splits)
if err != nil {
return nil, tabletserver.ToGRPCError(err)
}
return &querypb.SplitQueryResponse{Queries: qs}, nil
}
开发者ID:littleyang,项目名称:vitess,代码行数:21,代码来源:server.go
示例19: GetSessionId
// GetSessionId is part of the queryservice.QueryServer interface
func (q *query) GetSessionId(ctx context.Context, request *querypb.GetSessionIdRequest) (response *querypb.GetSessionIdResponse, err error) {
defer q.server.HandlePanic(&err)
sessionID, err := q.server.GetSessionId(request.Keyspace, request.Shard)
if err != nil {
return nil, tabletserver.ToGRPCError(err)
}
return &querypb.GetSessionIdResponse{
SessionId: sessionID,
}, nil
}
开发者ID:littleyang,项目名称:vitess,代码行数:13,代码来源:server.go
示例20: Rollback
// Rollback is part of the queryservice.QueryServer interface
func (q *query) Rollback(ctx context.Context, request *pb.RollbackRequest) (response *pb.RollbackResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
if err := q.server.Rollback(ctx, request.Target, &proto.Session{
SessionId: request.SessionId,
TransactionId: request.TransactionId,
}); err != nil {
return nil, tabletserver.ToGRPCError(err)
}
return &pb.RollbackResponse{}, nil
}
开发者ID:hadoop835,项目名称:vitess,代码行数:16,代码来源:server.go
注:本文中的github.com/youtube/vitess/go/vt/tabletserver.ToGRPCError函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论