예제 #1
0
파일: server.go 프로젝트: khanchan/vitess
// 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
}
예제 #2
0
파일: server.go 프로젝트: UGuarder/vitess
// 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 = callinfo.GRPCCallInfo(ctx)

	reply := new(proto.QueryResultList)
	execErr := q.server.ExecuteBatch(ctx, &proto.QueryList{
		Queries:       proto.Proto3ToBoundQueryList(request.Queries),
		SessionId:     request.SessionId,
		TransactionId: request.TransactionId,
	}, reply)
	if execErr != nil {
		return &pb.ExecuteBatchResponse{
			Error: tabletserver.TabletErrorToRPCError(execErr),
		}, nil
	}
	return &pb.ExecuteBatchResponse{
		Results: proto.QueryResultListToProto3(reply.List),
	}, nil
}