// 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.AddVtGateError(vtgErr, &qr.Err) // 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 }
// Rollback2 is the RPC version of vtgateservice.VTGateService method func (vtg *VTGate) Rollback2(ctx context.Context, request *proto.RollbackRequest, reply *proto.RollbackResponse) (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.Rollback(ctx, request.Session) vtgate.AddVtGateError(vtgErr, &reply.Err) return nil }
// Begin2 is the RPC version of vtgateservice.VTGateService method func (vtg *VTGate) Begin2(ctx context.Context, request *proto.BeginRequest, reply *proto.BeginResponse) (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")) // Don't pass in a nil pointer reply.Session = &pbg.Session{} vtgErr := vtg.server.Begin(ctx, reply.Session) reply.Session = sessionToRPC(reply.Session) vtgate.AddVtGateError(vtgErr, &reply.Err) return nil }
// ExecuteBatchKeyspaceIds is the RPC version of // vtgateservice.VTGateService method func (vtg *VTGate) ExecuteBatchKeyspaceIds(ctx context.Context, request *proto.KeyspaceIdBatchQuery, reply *proto.QueryResultList) (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.ExecuteBatchKeyspaceIds(ctx, request.Queries, topo.TabletTypeToProto(request.TabletType), request.AsTransaction, request.Session, reply) vtgate.AddVtGateError(vtgErr, &reply.Err) return nil }
// SplitQuery is the RPC version of vtgateservice.VTGateService method func (vtg *VTGate) SplitQuery(ctx context.Context, request *proto.SplitQueryRequest, reply *proto.SplitQueryResult) (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")) splits, vtgErr := vtg.server.SplitQuery(ctx, request.Keyspace, request.Query.Sql, request.Query.BindVariables, request.SplitColumn, request.SplitCount) reply.Splits = splits vtgate.AddVtGateError(vtgErr, &reply.Err) return nil }
// 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")) sessionFromRPC(request.Session) vtgErr := vtg.server.Execute(ctx, request.Sql, request.BindVariables, request.TabletType, request.Session, request.NotInTransaction, reply) reply.Session = sessionToRPC(reply.Session) vtgate.AddVtGateError(vtgErr, &reply.Err) return nil }
// StreamExecute2 is the RPC version of vtgateservice.VTGateService method func (vtg *VTGate) StreamExecute2(ctx context.Context, request *proto.Query, 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.StreamExecute(ctx, request.Sql, request.BindVariables, request.TabletType, func(value *proto.QueryResult) error { return sendReply(value) }) if vtgErr == nil { return nil } // If there was an app error, send a QueryResult back with it. qr := new(proto.QueryResult) vtgate.AddVtGateError(vtgErr, &qr.Err) return sendReply(qr) }
// 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.Sql, request.BindVariables, request.Keyspace, request.EntityColumnName, proto.EntityIdsToProto(request.EntityKeyspaceIDs), topo.TabletTypeToProto(request.TabletType), request.Session, request.NotInTransaction, reply) vtgate.AddVtGateError(vtgErr, &reply.Err) return nil }
// ExecuteBatchShard is the RPC version of vtgateservice.VTGateService method func (vtg *VTGate) ExecuteBatchShard(ctx context.Context, request *proto.BatchQueryShard, reply *proto.QueryResultList) (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")) sessionFromRPC(request.Session) qs, err := proto.BoundShardQueriesToProto(request.Queries) if err != nil { return err } vtgErr := vtg.server.ExecuteBatchShards(ctx, qs, request.TabletType, request.AsTransaction, request.Session, reply) reply.Session = sessionToRPC(reply.Session) vtgate.AddVtGateError(vtgErr, &reply.Err) return nil }