本文整理汇总了Golang中github.com/youtube/vitess/go/vt/callinfo.GRPCCallInfo函数的典型用法代码示例。如果您正苦于以下问题:Golang GRPCCallInfo函数的具体用法?Golang GRPCCallInfo怎么用?Golang GRPCCallInfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GRPCCallInfo函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: 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
示例2: ExecuteKeyspaceIds
// ExecuteKeyspaceIds is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGate) ExecuteKeyspaceIds(ctx context.Context, request *pb.ExecuteKeyspaceIdsRequest) (response *pb.ExecuteKeyspaceIdsResponse, err error) {
defer vtg.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.CallerId,
callerid.NewImmediateCallerID("grpc client"))
reply := new(proto.QueryResult)
bv, err := tproto.Proto3ToBindVariables(request.Query.BindVariables)
if err != nil {
return nil, vterrors.ToGRPCError(err)
}
executeErr := vtg.server.ExecuteKeyspaceIds(ctx,
string(request.Query.Sql),
bv,
request.Keyspace,
request.KeyspaceIds,
request.TabletType,
request.Session,
request.NotInTransaction,
reply)
response = &pb.ExecuteKeyspaceIdsResponse{
Error: vtgate.RPCErrorToVtRPCError(reply.Err),
}
if executeErr != nil {
return nil, vterrors.ToGRPCError(executeErr)
}
response.Result = sqltypes.ResultToProto3(reply.Result)
response.Session = reply.Session
return response, nil
}
开发者ID:tjyang,项目名称:vitess,代码行数:30,代码来源:server.go
示例3: ExecuteBatchShards
// ExecuteBatchShards is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGate) ExecuteBatchShards(ctx context.Context, request *pb.ExecuteBatchShardsRequest) (response *pb.ExecuteBatchShardsResponse, err error) {
defer vtg.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.CallerId,
callerid.NewImmediateCallerID("grpc client"))
reply := new(proto.QueryResultList)
executeErr := vtg.server.ExecuteBatchShards(ctx,
proto.ProtoToBoundShardQueries(request.Queries),
request.TabletType,
request.AsTransaction,
proto.ProtoToSession(request.Session),
reply)
response = &pb.ExecuteBatchShardsResponse{
Error: vtgate.VtGateErrorToVtRPCError(executeErr, reply.Error),
}
if executeErr == nil {
response.Results = tproto.QueryResultListToProto3(reply.List)
response.Session = proto.SessionToProto(reply.Session)
return response, nil
}
if *vtgate.RPCErrorOnlyInReply {
return response, nil
}
return nil, executeErr
}
开发者ID:payintel,项目名称:vitess,代码行数:26,代码来源:server.go
示例4: SetMaster
func (s *server) SetMaster(ctx context.Context, request *tabletmanagerdatapb.SetMasterRequest) (*tabletmanagerdatapb.SetMasterResponse, error) {
ctx = callinfo.GRPCCallInfo(ctx)
response := &tabletmanagerdatapb.SetMasterResponse{}
return response, s.agent.RPCWrapLockAction(ctx, actionnode.TabletActionSetMaster, request, response, true, func() error {
return s.agent.SetMaster(ctx, request.Parent, request.TimeCreatedNs, request.ForceStartSlave)
})
}
开发者ID:tjyang,项目名称:vitess,代码行数:7,代码来源:server.go
示例5: SetReadOnly
func (s *server) SetReadOnly(ctx context.Context, request *tabletmanagerdatapb.SetReadOnlyRequest) (*tabletmanagerdatapb.SetReadOnlyResponse, error) {
ctx = callinfo.GRPCCallInfo(ctx)
response := &tabletmanagerdatapb.SetReadOnlyResponse{}
return response, s.agent.RPCWrapLockAction(ctx, actionnode.TabletActionSetReadOnly, request, response, true, func() error {
return s.agent.SetReadOnly(ctx, true)
})
}
开发者ID:tjyang,项目名称:vitess,代码行数:7,代码来源:server.go
示例6: StartBlp
func (s *server) StartBlp(ctx context.Context, request *tabletmanagerdatapb.StartBlpRequest) (*tabletmanagerdatapb.StartBlpResponse, error) {
ctx = callinfo.GRPCCallInfo(ctx)
response := &tabletmanagerdatapb.StartBlpResponse{}
return response, s.agent.RPCWrapLock(ctx, actionnode.TabletActionStartBLP, request, response, true, func() error {
return s.agent.StartBlp(ctx)
})
}
开发者ID:tjyang,项目名称:vitess,代码行数:7,代码来源:server.go
示例7: InitSlave
func (s *server) InitSlave(ctx context.Context, request *tabletmanagerdatapb.InitSlaveRequest) (*tabletmanagerdatapb.InitSlaveResponse, error) {
ctx = callinfo.GRPCCallInfo(ctx)
response := &tabletmanagerdatapb.InitSlaveResponse{}
return response, s.agent.RPCWrapLockAction(ctx, actionnode.TabletActionInitSlave, request, response, true, func() error {
return s.agent.InitSlave(ctx, request.Parent, request.ReplicationPosition, request.TimeCreatedNs)
})
}
开发者ID:tjyang,项目名称:vitess,代码行数:7,代码来源:server.go
示例8: PopulateReparentJournal
func (s *server) PopulateReparentJournal(ctx context.Context, request *pb.PopulateReparentJournalRequest) (*pb.PopulateReparentJournalResponse, error) {
ctx = callinfo.GRPCCallInfo(ctx)
response := &pb.PopulateReparentJournalResponse{}
return response, s.agent.RPCWrap(ctx, actionnode.TabletActionPopulateReparentJournal, request, response, func() error {
return s.agent.PopulateReparentJournal(ctx, request.TimeCreatedNs, request.ActionName, topo.ProtoToTabletAlias(request.MasterAlias), myproto.ProtoToReplicationPosition(request.ReplicationPosition))
})
}
开发者ID:ImadBouirmane,项目名称:vitess,代码行数:7,代码来源:server.go
示例9: InitSlave
func (s *server) InitSlave(ctx context.Context, request *pb.InitSlaveRequest) (*pb.InitSlaveResponse, error) {
ctx = callinfo.GRPCCallInfo(ctx)
response := &pb.InitSlaveResponse{}
return response, s.agent.RPCWrapLockAction(ctx, actionnode.TabletActionInitSlave, request, response, true, func() error {
return s.agent.InitSlave(ctx, topo.ProtoToTabletAlias(request.Parent), myproto.ProtoToReplicationPosition(request.ReplicationPosition), request.TimeCreatedNs)
})
}
开发者ID:ImadBouirmane,项目名称:vitess,代码行数:7,代码来源:server.go
示例10: BeginExecuteBatch
// BeginExecuteBatch is part of the queryservice.QueryServer interface
func (q *query) BeginExecuteBatch(ctx context.Context, request *querypb.BeginExecuteBatchRequest) (response *querypb.BeginExecuteBatchResponse, 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, vterrors.ToGRPCError(err)
}
results, transactionID, err := q.server.BeginExecuteBatch(ctx, request.Target, bql, request.AsTransaction, request.Options)
if err != nil {
// if we have a valid transactionID, return the error in-band
if transactionID != 0 {
return &querypb.BeginExecuteBatchResponse{
Error: vterrors.VtRPCErrorFromVtError(err),
TransactionId: transactionID,
}, nil
}
return nil, vterrors.ToGRPCError(err)
}
return &querypb.BeginExecuteBatchResponse{
Results: sqltypes.ResultsToProto3(results),
TransactionId: transactionID,
}, nil
}
开发者ID:dumbunny,项目名称:vitess,代码行数:28,代码来源:server.go
示例11: 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, vterrors.ToGRPCError(err)
}
splits := []querytypes.QuerySplit{}
splits, err = queryservice.CallCorrectSplitQuery(
q.server,
request.UseSplitQueryV2,
ctx,
request.Target,
bq.Sql,
bq.BindVariables,
request.SplitColumn,
request.SplitCount,
request.NumRowsPerQueryPart,
request.Algorithm)
if err != nil {
return nil, vterrors.ToGRPCError(err)
}
qs, err := querytypes.QuerySplitsToProto3(splits)
if err != nil {
return nil, vterrors.ToGRPCError(err)
}
return &querypb.SplitQueryResponse{Queries: qs}, nil
}
开发者ID:dumbunny,项目名称:vitess,代码行数:33,代码来源:server.go
示例12: BeginExecute
// BeginExecute is part of the queryservice.QueryServer interface
func (q *query) BeginExecute(ctx context.Context, request *querypb.BeginExecuteRequest) (response *querypb.BeginExecuteResponse, 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, vterrors.ToGRPCError(err)
}
result, transactionID, err := q.server.BeginExecute(ctx, request.Target, request.Query.Sql, bv)
if err != nil {
// if we have a valid transactionID, return the error in-band
if transactionID != 0 {
return &querypb.BeginExecuteResponse{
Error: vterrors.VtRPCErrorFromVtError(err),
TransactionId: transactionID,
}, nil
}
return nil, vterrors.ToGRPCError(err)
}
return &querypb.BeginExecuteResponse{
Result: sqltypes.ResultToProto3(result),
TransactionId: transactionID,
}, nil
}
开发者ID:erzel,项目名称:vitess,代码行数:28,代码来源:server.go
示例13: SplitQuery
// SplitQuery is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGate) SplitQuery(ctx context.Context, request *vtgatepb.SplitQueryRequest) (response *vtgatepb.SplitQueryResponse, err error) {
defer vtg.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.CallerId,
callerid.NewImmediateCallerID("grpc client"))
bv, err := querytypes.Proto3ToBindVariables(request.Query.BindVariables)
if err != nil {
return nil, vterrors.ToGRPCError(err)
}
splits, vtgErr := vtgateservice.CallCorrectSplitQuery(
vtg.server,
request.UseSplitQueryV2,
ctx,
request.Keyspace,
string(request.Query.Sql),
bv,
request.SplitColumn,
request.SplitCount,
request.NumRowsPerQueryPart,
request.Algorithm)
if vtgErr != nil {
return nil, vterrors.ToGRPCError(vtgErr)
}
return &vtgatepb.SplitQueryResponse{
Splits: splits,
}, nil
}
开发者ID:aaijazi,项目名称:vitess,代码行数:29,代码来源:server.go
示例14: 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
示例15: TabletExternallyReparented
func (s *server) TabletExternallyReparented(ctx context.Context, request *tabletmanagerdatapb.TabletExternallyReparentedRequest) (*tabletmanagerdatapb.TabletExternallyReparentedResponse, error) {
ctx = callinfo.GRPCCallInfo(ctx)
response := &tabletmanagerdatapb.TabletExternallyReparentedResponse{}
return response, s.agent.RPCWrapLock(ctx, actionnode.TabletActionExternallyReparented, request, response, false, func() error {
return s.agent.TabletExternallyReparented(ctx, request.ExternalId)
})
}
开发者ID:tjyang,项目名称:vitess,代码行数:7,代码来源:server.go
示例16: RunHealthCheck
func (s *server) RunHealthCheck(ctx context.Context, request *tabletmanagerdatapb.RunHealthCheckRequest) (response *tabletmanagerdatapb.RunHealthCheckResponse, err error) {
defer s.agent.HandleRPCPanic(ctx, "RunHealthCheck", request, response, false /*verbose*/, &err)
ctx = callinfo.GRPCCallInfo(ctx)
response = &tabletmanagerdatapb.RunHealthCheckResponse{}
s.agent.RunHealthCheck(ctx)
return response, nil
}
开发者ID:erzel,项目名称:vitess,代码行数:7,代码来源:server.go
示例17: WaitBlpPosition
func (s *server) WaitBlpPosition(ctx context.Context, request *tabletmanagerdatapb.WaitBlpPositionRequest) (*tabletmanagerdatapb.WaitBlpPositionResponse, error) {
ctx = callinfo.GRPCCallInfo(ctx)
response := &tabletmanagerdatapb.WaitBlpPositionResponse{}
return response, s.agent.RPCWrapLock(ctx, actionnode.TabletActionWaitBLPPosition, request, response, true, func() error {
return s.agent.WaitBlpPosition(ctx, request.BlpPosition, time.Duration(request.WaitTimeout))
})
}
开发者ID:tjyang,项目名称:vitess,代码行数:7,代码来源:server.go
示例18: Sleep
func (s *server) Sleep(ctx context.Context, request *tabletmanagerdatapb.SleepRequest) (response *tabletmanagerdatapb.SleepResponse, err error) {
defer s.agent.HandleRPCPanic(ctx, "Sleep", request, response, true /*verbose*/, &err)
ctx = callinfo.GRPCCallInfo(ctx)
response = &tabletmanagerdatapb.SleepResponse{}
s.agent.Sleep(ctx, time.Duration(request.Duration))
return response, nil
}
开发者ID:erzel,项目名称:vitess,代码行数:7,代码来源:server.go
示例19: PopulateReparentJournal
func (s *server) PopulateReparentJournal(ctx context.Context, request *tabletmanagerdatapb.PopulateReparentJournalRequest) (*tabletmanagerdatapb.PopulateReparentJournalResponse, error) {
ctx = callinfo.GRPCCallInfo(ctx)
response := &tabletmanagerdatapb.PopulateReparentJournalResponse{}
return response, s.agent.RPCWrap(ctx, actionnode.TabletActionPopulateReparentJournal, request, response, func() error {
return s.agent.PopulateReparentJournal(ctx, request.TimeCreatedNs, request.ActionName, request.MasterAlias, request.ReplicationPosition)
})
}
开发者ID:tjyang,项目名称:vitess,代码行数:7,代码来源:server.go
示例20: 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.GetEffectiveCallerId(),
request.GetImmediateCallerId(),
)
seErr := q.server.StreamExecute(ctx, &proto.Query{
Sql: string(request.Query.Sql),
BindVariables: proto.Proto3ToBindVariables(request.Query.BindVariables),
SessionId: request.SessionId,
}, func(reply *mproto.QueryResult) error {
return stream.Send(&pb.StreamExecuteResponse{
Result: mproto.QueryResultToProto3(reply),
})
})
if seErr != nil {
response := &pb.StreamExecuteResponse{
Error: tabletserver.TabletErrorToRPCError(seErr),
}
if err := stream.Send(response); err != nil {
return err
}
}
return nil
}
开发者ID:afrolovskiy,项目名称:vitess,代码行数:26,代码来源:server.go
注:本文中的github.com/youtube/vitess/go/vt/callinfo.GRPCCallInfo函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论