• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang proto.QueryResultToProto3函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/youtube/vitess/go/mysql/proto.QueryResultToProto3函数的典型用法代码示例。如果您正苦于以下问题:Golang QueryResultToProto3函数的具体用法?Golang QueryResultToProto3怎么用?Golang QueryResultToProto3使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了QueryResultToProto3函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: 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


示例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)
	executeErr := vtg.server.ExecuteKeyspaceIds(ctx,
		string(request.Query.Sql),
		tproto.Proto3ToBindVariables(request.Query.BindVariables),
		request.Keyspace,
		key.ProtoToKeyspaceIds(request.KeyspaceIds),
		request.TabletType,
		proto.ProtoToSession(request.Session),
		request.NotInTransaction,
		reply)
	response = &pb.ExecuteKeyspaceIdsResponse{
		Error: vtgate.VtGateErrorToVtRPCError(executeErr, reply.Error),
	}
	if executeErr == nil {
		response.Result = mproto.QueryResultToProto3(reply.Result)
		response.Session = proto.SessionToProto(reply.Session)
		return response, nil
	}
	if *vtgate.RPCErrorOnlyInReply {
		return response, nil
	}
	return nil, executeErr
}
开发者ID:payintel,项目名称:vitess,代码行数:29,代码来源:server.go


示例3: 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)
	query := &proto.KeyspaceIdQuery{
		Sql:              string(request.Query.Sql),
		BindVariables:    tproto.Proto3ToBindVariables(request.Query.BindVariables),
		Keyspace:         request.Keyspace,
		KeyspaceIds:      key.ProtoToKeyspaceIds(request.KeyspaceIds),
		TabletType:       topo.ProtoToTabletType(request.TabletType),
		Session:          proto.ProtoToSession(request.Session),
		NotInTransaction: request.NotInTransaction,
	}
	reply := new(proto.QueryResult)
	executeErr := vtg.server.ExecuteKeyspaceIds(ctx, query, reply)
	response = &pb.ExecuteKeyspaceIdsResponse{
		Error: vtgate.VtGateErrorToVtRPCError(executeErr, reply.Error),
	}
	if executeErr == nil {
		response.Result = mproto.QueryResultToProto3(reply.Result)
		response.Session = proto.SessionToProto(reply.Session)
		return response, nil
	}
	if *vtgate.RPCErrorOnlyInReply {
		return response, nil
	}
	return nil, executeErr
}
开发者ID:afrolovskiy,项目名称:vitess,代码行数:27,代码来源:server.go


示例4: ExecuteEntityIds

// ExecuteEntityIds is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGateP3) ExecuteEntityIds(ctx context.Context, request *pb.ExecuteEntityIdsRequest, response *pb.ExecuteEntityIdsResponse) (err error) {
	defer vtg.server.HandlePanic(&err)
	ctx, cancel := context.WithDeadline(ctx, time.Now().Add(*rpcTimeout))
	defer cancel()
	ctx = callerid.NewContext(ctx,
		request.CallerId,
		callerid.NewImmediateCallerID("bsonp3 client"))
	reply := new(proto.QueryResult)
	executeErr := vtg.server.ExecuteEntityIds(ctx,
		string(request.Query.Sql),
		tproto.Proto3ToBindVariables(request.Query.BindVariables),
		request.Keyspace,
		request.EntityColumnName,
		request.EntityKeyspaceIds,
		request.TabletType,
		proto.ProtoToSession(request.Session),
		request.NotInTransaction,
		reply)
	if executeErr == nil {
		response.Error = vtgate.RPCErrorToVtRPCError(reply.Err)
		response.Result = mproto.QueryResultToProto3(reply.Result)
		response.Session = proto.SessionToProto(reply.Session)
	}
	return vterrors.ToJSONError(executeErr)
}
开发者ID:richarwu,项目名称:vitess,代码行数:26,代码来源:server.go


示例5: 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


示例6: StreamExecuteKeyRanges2

// StreamExecuteKeyRanges2 is the RPC version of
// vtgateservice.VTGateService method
func (vtg *VTGateP3) StreamExecuteKeyRanges2(ctx context.Context, request *pb.StreamExecuteKeyRangesRequest, sendReply func(interface{}) error) (err error) {
	defer vtg.server.HandlePanic(&err)
	ctx = callerid.NewContext(ctx,
		request.CallerId,
		callerid.NewImmediateCallerID("gorpc client"))
	vtgErr := vtg.server.StreamExecuteKeyRanges(ctx,
		string(request.Query.Sql),
		tproto.Proto3ToBindVariables(request.Query.BindVariables),
		request.Keyspace,
		request.KeyRanges,
		request.TabletType,
		func(reply *proto.QueryResult) error {
			return sendReply(&pb.StreamExecuteKeyRangesResponse{
				Error:  vtgate.VtGateErrorToVtRPCError(nil, reply.Error),
				Result: mproto.QueryResultToProto3(reply.Result),
			})
		})
	if vtgErr == nil {
		return nil
	}
	if *vtgate.RPCErrorOnlyInReply {
		// If there was an app error, send a QueryResult back with it.
		// 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(&pb.StreamExecuteKeyRangesResponse{
			Error: vtgate.VtGateErrorToVtRPCError(vtgErr, ""),
		})
	}
	return vtgErr
}
开发者ID:ruiaylin,项目名称:vitess,代码行数:35,代码来源:server.go


示例7: ExecuteKeyspaceIds

// ExecuteKeyspaceIds is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGateP3) ExecuteKeyspaceIds(ctx context.Context, request *pb.ExecuteKeyspaceIdsRequest, response *pb.ExecuteKeyspaceIdsResponse) (err error) {
	defer vtg.server.HandlePanic(&err)
	ctx, cancel := context.WithDeadline(ctx, time.Now().Add(*rpcTimeout))
	defer cancel()
	ctx = callerid.NewContext(ctx,
		request.CallerId,
		callerid.NewImmediateCallerID("gorpc client"))
	reply := &proto.QueryResult{}
	vtgErr := vtg.server.ExecuteKeyspaceIds(ctx,
		string(request.Query.Sql),
		tproto.Proto3ToBindVariables(request.Query.BindVariables),
		request.Keyspace,
		request.KeyspaceIds,
		request.TabletType,
		proto.ProtoToSession(request.Session),
		request.NotInTransaction,
		reply)
	response.Error = vtgate.VtGateErrorToVtRPCError(vtgErr, reply.Error)
	response.Result = mproto.QueryResultToProto3(reply.Result)
	response.Session = proto.SessionToProto(reply.Session)
	if *vtgate.RPCErrorOnlyInReply {
		return nil
	}
	return vtgErr
}
开发者ID:ruiaylin,项目名称:vitess,代码行数:26,代码来源:server.go


示例8: 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 {
		response.Result, executeErr = mproto.QueryResultToProto3(reply.Result)
		if executeErr == nil {
			response.Session = reply.Session
			return response, nil
		}
	}
	return nil, vterrors.ToGRPCError(executeErr)
}
开发者ID:forndb,项目名称:vitess,代码行数:32,代码来源:server.go


示例9: 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


示例10: QueryResultListToProto3

// QueryResultListToProto3 changes the internal array of QueryResult to the proto3 version
func QueryResultListToProto3(results []mproto.QueryResult) []*pb.QueryResult {
	if len(results) == 0 {
		return nil
	}
	result := make([]*pb.QueryResult, len(results))
	for i := range results {
		result[i] = mproto.QueryResultToProto3(&results[i])
	}
	return result
}
开发者ID:hadmagic,项目名称:vitess,代码行数:11,代码来源:proto3.go


示例11: ExecuteFetchAsApp

func (s *server) ExecuteFetchAsApp(ctx context.Context, request *pb.ExecuteFetchAsAppRequest) (*pb.ExecuteFetchAsAppResponse, error) {
	ctx = callinfo.GRPCCallInfo(ctx)
	response := &pb.ExecuteFetchAsAppResponse{}
	return response, s.agent.RPCWrap(ctx, actionnode.TabletActionExecuteFetchAsApp, request, response, func() error {
		qr, err := s.agent.ExecuteFetchAsApp(ctx, request.Query, int(request.MaxRows), request.WantFields)
		if err == nil {
			response.Result = mproto.QueryResultToProto3(qr)
		}
		return err
	})
}
开发者ID:haoqoo,项目名称:vitess,代码行数:11,代码来源:server.go


示例12: ExecuteFetchAsDba

func (s *server) ExecuteFetchAsDba(ctx context.Context, request *pb.ExecuteFetchAsDbaRequest) (*pb.ExecuteFetchAsDbaResponse, error) {
	ctx = callinfo.GRPCCallInfo(ctx)
	response := &pb.ExecuteFetchAsDbaResponse{}
	return response, s.agent.RPCWrap(ctx, actionnode.TabletActionExecuteFetchAsDba, request, response, func() error {
		qr, err := s.agent.ExecuteFetchAsDba(ctx, request.Query, request.DbName, int(request.MaxRows), request.WantFields, request.DisableBinlogs, request.ReloadSchema)
		if err != nil {
			return err
		}
		response.Result, err = mproto.QueryResultToProto3(qr)
		return err
	})
}
开发者ID:khanchan,项目名称:vitess,代码行数:12,代码来源:server.go


示例13: StreamExecute

// StreamExecute is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGate) StreamExecute(request *pb.StreamExecuteRequest, stream pbs.Vitess_StreamExecuteServer) (err error) {
	defer vtg.server.HandlePanic(&err)

	query := &proto.Query{
		Sql:           string(request.Query.Sql),
		BindVariables: tproto.Proto3ToBindVariables(request.Query.BindVariables),
		TabletType:    topo.ProtoToTabletType(request.TabletType),
	}
	return vtg.server.StreamExecute(stream.Context(), query, func(value *proto.QueryResult) error {
		return stream.Send(&pb.StreamExecuteResponse{
			Result: mproto.QueryResultToProto3(value.Result),
		})
	})
}
开发者ID:afrolovskiy,项目名称:vitess,代码行数:15,代码来源:server.go


示例14: QueryResultListToProto3

// QueryResultListToProto3 changes the internal array of QueryResult to the proto3 version
func QueryResultListToProto3(results []mproto.QueryResult) ([]*pb.QueryResult, error) {
	if len(results) == 0 {
		return nil, nil
	}
	result := make([]*pb.QueryResult, len(results))
	var err error
	for i := range results {
		result[i], err = mproto.QueryResultToProto3(&results[i])
		if err != nil {
			return nil, err
		}
	}
	return result, nil
}
开发者ID:khanchan,项目名称:vitess,代码行数:15,代码来源:proto3.go


示例15: StreamExecute

// StreamExecute is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGate) StreamExecute(request *pb.StreamExecuteRequest, stream pbs.Vitess_StreamExecuteServer) (err error) {
	defer vtg.server.HandlePanic(&err)
	ctx := callerid.NewContext(callinfo.GRPCCallInfo(stream.Context()),
		request.CallerId,
		callerid.NewImmediateCallerID("grpc client"))
	return vtg.server.StreamExecute(ctx,
		string(request.Query.Sql),
		tproto.Proto3ToBindVariables(request.Query.BindVariables),
		request.TabletType,
		func(value *proto.QueryResult) error {
			return stream.Send(&pb.StreamExecuteResponse{
				Result: mproto.QueryResultToProto3(value.Result),
			})
		})
}
开发者ID:payintel,项目名称:vitess,代码行数:16,代码来源:server.go


示例16: 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,
	)
	return q.server.StreamExecute(ctx, request.Target, &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),
		})
	})
}
开发者ID:haoqoo,项目名称:vitess,代码行数:17,代码来源:server.go


示例17: StreamExecute

// StreamExecute is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGateP3) StreamExecute(ctx context.Context, request *pb.StreamExecuteRequest, sendReply func(interface{}) error) (err error) {
	defer vtg.server.HandlePanic(&err)
	ctx = callerid.NewContext(ctx,
		request.CallerId,
		callerid.NewImmediateCallerID("bsonp3 client"))
	vtgErr := vtg.server.StreamExecute(ctx,
		string(request.Query.Sql),
		tproto.Proto3ToBindVariables(request.Query.BindVariables),
		request.TabletType,
		func(reply *proto.QueryResult) error {
			return sendReply(&pb.StreamExecuteResponse{
				Result: mproto.QueryResultToProto3(reply.Result),
			})
		})
	return vterrors.ToJSONError(vtgErr)
}
开发者ID:richarwu,项目名称:vitess,代码行数:17,代码来源:server.go


示例18: StreamExecuteKeyRanges

// StreamExecuteKeyRanges is the RPC version of
// vtgateservice.VTGateService method
func (vtg *VTGateP3) StreamExecuteKeyRanges(ctx context.Context, request *pb.StreamExecuteKeyRangesRequest, sendReply func(interface{}) error) (err error) {
	defer vtg.server.HandlePanic(&err)
	ctx = callerid.NewContext(ctx,
		request.CallerId,
		callerid.NewImmediateCallerID("gorpc client"))
	return vtg.server.StreamExecuteKeyRanges(ctx,
		string(request.Query.Sql),
		tproto.Proto3ToBindVariables(request.Query.BindVariables),
		request.Keyspace,
		key.ProtoToKeyRanges(request.KeyRanges),
		request.TabletType,
		func(reply *proto.QueryResult) error {
			return sendReply(&pb.StreamExecuteKeyRangesResponse{
				Error:  vtgate.VtGateErrorToVtRPCError(nil, reply.Error),
				Result: mproto.QueryResultToProto3(reply.Result),
			})
		})
}
开发者ID:payintel,项目名称:vitess,代码行数:20,代码来源:server.go


示例19: StreamExecuteKeyspaceIds

// StreamExecuteKeyspaceIds is the RPC version of
// vtgateservice.VTGateService method
func (vtg *VTGate) StreamExecuteKeyspaceIds(request *pb.StreamExecuteKeyspaceIdsRequest, stream pbs.Vitess_StreamExecuteKeyspaceIdsServer) (err error) {
	defer vtg.server.HandlePanic(&err)
	ctx := callerid.NewContext(callinfo.GRPCCallInfo(stream.Context()),
		request.CallerId,
		callerid.NewImmediateCallerID("grpc client"))
	query := &proto.KeyspaceIdQuery{
		Sql:           string(request.Query.Sql),
		BindVariables: tproto.Proto3ToBindVariables(request.Query.BindVariables),
		Keyspace:      request.Keyspace,
		KeyspaceIds:   key.ProtoToKeyspaceIds(request.KeyspaceIds),
		TabletType:    topo.ProtoToTabletType(request.TabletType),
	}
	return vtg.server.StreamExecuteKeyspaceIds(ctx, query, func(value *proto.QueryResult) error {
		return stream.Send(&pb.StreamExecuteKeyspaceIdsResponse{
			Result: mproto.QueryResultToProto3(value.Result),
		})
	})
}
开发者ID:haoqoo,项目名称:vitess,代码行数:20,代码来源:server.go


示例20: 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)
	if err := q.server.Execute(ctx, request.Target, &proto.Query{
		Sql:           string(request.Query.Sql),
		BindVariables: proto.Proto3ToBindVariables(request.Query.BindVariables),
		SessionId:     request.SessionId,
		TransactionId: request.TransactionId,
	}, reply); err != nil {
		return nil, grpc.Errorf(codes.Internal, "%v", err)
	}
	return &pb.ExecuteResponse{
		Result: mproto.QueryResultToProto3(reply),
	}, nil
}
开发者ID:payintel,项目名称:vitess,代码行数:20,代码来源:server.go



注:本文中的github.com/youtube/vitess/go/mysql/proto.QueryResultToProto3函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang proto.QueryResult类代码示例发布时间:2022-05-28
下一篇:
Golang proto.Proto3ToQueryResults函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap