diff --git a/go/cmd/vtgateclienttest/errors.go b/go/cmd/vtgateclienttest/errors.go index 9cfc832fe7..659804a6dd 100644 --- a/go/cmd/vtgateclienttest/errors.go +++ b/go/cmd/vtgateclienttest/errors.go @@ -10,6 +10,7 @@ import ( log "github.com/golang/glog" "github.com/youtube/vitess/go/tb" + "github.com/youtube/vitess/go/vt/topo" "github.com/youtube/vitess/go/vt/vtgate/proto" "github.com/youtube/vitess/go/vt/vtgate/vtgateservice" "golang.org/x/net/context" @@ -115,6 +116,13 @@ func (c *errorClient) SplitQuery(ctx context.Context, req *proto.SplitQueryReque return c.fallback.SplitQuery(ctx, req, reply) } +func (c *errorClient) GetSrvKeyspace(ctx context.Context, keyspace string) (*topo.SrvKeyspace, error) { + if keyspace == "error" { + return nil, fmt.Errorf("vtgate test client, errorClient.GetSrvKeyspace returning error") + } + return c.fallback.GetSrvKeyspace(ctx, keyspace) +} + func (c *errorClient) HandlePanic(err *error) { if x := recover(); x != nil { log.Errorf("Uncaught panic:\n%v\n%s", x, tb.Stack(4)) diff --git a/go/cmd/vtgateclienttest/terminal.go b/go/cmd/vtgateclienttest/terminal.go index 34d740293b..5ede9c7b0c 100644 --- a/go/cmd/vtgateclienttest/terminal.go +++ b/go/cmd/vtgateclienttest/terminal.go @@ -11,6 +11,7 @@ import ( log "github.com/golang/glog" "github.com/youtube/vitess/go/tb" + "github.com/youtube/vitess/go/vt/topo" "github.com/youtube/vitess/go/vt/vtgate/proto" "golang.org/x/net/context" ) @@ -85,6 +86,10 @@ func (c *terminalClient) SplitQuery(ctx context.Context, req *proto.SplitQueryRe return errTerminal } +func (c *terminalClient) GetSrvKeyspace(ctx context.Context, keyspace string) (*topo.SrvKeyspace, error) { + return nil, errTerminal +} + func (c *terminalClient) HandlePanic(err *error) { if x := recover(); x != nil { log.Errorf("Uncaught panic:\n%v\n%s", x, tb.Stack(4)) diff --git a/go/vt/client/fakeserver_test.go b/go/vt/client/fakeserver_test.go index 2021081ae8..157a79ce59 100644 --- a/go/vt/client/fakeserver_test.go +++ b/go/vt/client/fakeserver_test.go @@ -131,6 +131,11 @@ func (f *fakeVTGateService) SplitQuery(ctx context.Context, req *proto.SplitQuer return nil } +// GetSrvKeyspace is part of the VTGateService interface +func (f *fakeVTGateService) GetSrvKeyspace(ctx context.Context, keyspace string) (*topo.SrvKeyspace, error) { + return &topo.SrvKeyspace{}, nil +} + // HandlePanic is part of the VTGateService interface func (f *fakeVTGateService) HandlePanic(err *error) { if x := recover(); x != nil { diff --git a/go/vt/proto/vtgate/vtgate.pb.go b/go/vt/proto/vtgate/vtgate.pb.go index 42a7deeec8..273b89a6df 100644 --- a/go/vt/proto/vtgate/vtgate.pb.go +++ b/go/vt/proto/vtgate/vtgate.pb.go @@ -42,6 +42,8 @@ It has these top-level messages: RollbackResponse SplitQueryRequest SplitQueryResponse + GetSrvKeyspaceRequest + GetSrvKeyspaceResponse */ package vtgate @@ -1084,6 +1086,31 @@ func (m *SplitQueryResponse_Part) GetShardPart() *SplitQueryResponse_ShardPart { return nil } +// GetSrvKeyspaceRequest is the payload to GetSrvKeyspace +type GetSrvKeyspaceRequest struct { + Keyspace string `protobuf:"bytes,1,opt,name=keyspace" json:"keyspace,omitempty"` +} + +func (m *GetSrvKeyspaceRequest) Reset() { *m = GetSrvKeyspaceRequest{} } +func (m *GetSrvKeyspaceRequest) String() string { return proto.CompactTextString(m) } +func (*GetSrvKeyspaceRequest) ProtoMessage() {} + +// GetSrvKeyspaceResponse is the returned value from GetSrvKeyspace +type GetSrvKeyspaceResponse struct { + SrvKeyspace *topodata.SrvKeyspace `protobuf:"bytes,1,opt,name=srv_keyspace" json:"srv_keyspace,omitempty"` +} + +func (m *GetSrvKeyspaceResponse) Reset() { *m = GetSrvKeyspaceResponse{} } +func (m *GetSrvKeyspaceResponse) String() string { return proto.CompactTextString(m) } +func (*GetSrvKeyspaceResponse) ProtoMessage() {} + +func (m *GetSrvKeyspaceResponse) GetSrvKeyspace() *topodata.SrvKeyspace { + if m != nil { + return m.SrvKeyspace + } + return nil +} + func init() { proto.RegisterEnum("vtgate.ExecuteEntityIdsRequest_EntityId_Type", ExecuteEntityIdsRequest_EntityId_Type_name, ExecuteEntityIdsRequest_EntityId_Type_value) } diff --git a/go/vt/proto/vtgateservice/vtgateservice.pb.go b/go/vt/proto/vtgateservice/vtgateservice.pb.go index ebec77146b..b17d035520 100644 --- a/go/vt/proto/vtgateservice/vtgateservice.pb.go +++ b/go/vt/proto/vtgateservice/vtgateservice.pb.go @@ -65,6 +65,14 @@ type VitessClient interface { Rollback(ctx context.Context, in *vtgate.RollbackRequest, opts ...grpc.CallOption) (*vtgate.RollbackResponse, error) // Split a query into non-overlapping sub queries SplitQuery(ctx context.Context, in *vtgate.SplitQueryRequest, opts ...grpc.CallOption) (*vtgate.SplitQueryResponse, error) + // GetSrvKeyspace returns a SrvKeyspace object (as seen by this vtgate). + // This method is provided as a convenient way for clients to take a + // look at the sharding configuration for a Keyspace. Looking at the + // sharding information should not be used for routing queries (as the + // information may change, use the Execute calls for that). + // It is convenient for monitoring applications for instance, or if + // using custom sharding. + GetSrvKeyspace(ctx context.Context, in *vtgate.GetSrvKeyspaceRequest, opts ...grpc.CallOption) (*vtgate.GetSrvKeyspaceResponse, error) } type vitessClient struct { @@ -302,6 +310,15 @@ func (c *vitessClient) SplitQuery(ctx context.Context, in *vtgate.SplitQueryRequ return out, nil } +func (c *vitessClient) GetSrvKeyspace(ctx context.Context, in *vtgate.GetSrvKeyspaceRequest, opts ...grpc.CallOption) (*vtgate.GetSrvKeyspaceResponse, error) { + out := new(vtgate.GetSrvKeyspaceResponse) + err := grpc.Invoke(ctx, "/vtgateservice.Vitess/GetSrvKeyspace", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // Server API for Vitess service type VitessServer interface { @@ -340,6 +357,14 @@ type VitessServer interface { Rollback(context.Context, *vtgate.RollbackRequest) (*vtgate.RollbackResponse, error) // Split a query into non-overlapping sub queries SplitQuery(context.Context, *vtgate.SplitQueryRequest) (*vtgate.SplitQueryResponse, error) + // GetSrvKeyspace returns a SrvKeyspace object (as seen by this vtgate). + // This method is provided as a convenient way for clients to take a + // look at the sharding configuration for a Keyspace. Looking at the + // sharding information should not be used for routing queries (as the + // information may change, use the Execute calls for that). + // It is convenient for monitoring applications for instance, or if + // using custom sharding. + GetSrvKeyspace(context.Context, *vtgate.GetSrvKeyspaceRequest) (*vtgate.GetSrvKeyspaceResponse, error) } func RegisterVitessServer(s *grpc.Server, srv VitessServer) { @@ -562,6 +587,18 @@ func _Vitess_SplitQuery_Handler(srv interface{}, ctx context.Context, codec grpc return out, nil } +func _Vitess_GetSrvKeyspace_Handler(srv interface{}, ctx context.Context, codec grpc.Codec, buf []byte) (interface{}, error) { + in := new(vtgate.GetSrvKeyspaceRequest) + if err := codec.Unmarshal(buf, in); err != nil { + return nil, err + } + out, err := srv.(VitessServer).GetSrvKeyspace(ctx, in) + if err != nil { + return nil, err + } + return out, nil +} + var _Vitess_serviceDesc = grpc.ServiceDesc{ ServiceName: "vtgateservice.Vitess", HandlerType: (*VitessServer)(nil), @@ -610,6 +647,10 @@ var _Vitess_serviceDesc = grpc.ServiceDesc{ MethodName: "SplitQuery", Handler: _Vitess_SplitQuery_Handler, }, + { + MethodName: "GetSrvKeyspace", + Handler: _Vitess_GetSrvKeyspace_Handler, + }, }, Streams: []grpc.StreamDesc{ { diff --git a/go/vt/topo/proto3.go b/go/vt/topo/proto3.go index 3104e0ec15..ef97f88586 100644 --- a/go/vt/topo/proto3.go +++ b/go/vt/topo/proto3.go @@ -85,3 +85,60 @@ func ProtoToTablet(t *pb.Tablet) *Tablet { } return result } + +// SrvKeyspaceToProto turns a Tablet into a proto +func SrvKeyspaceToProto(s *SrvKeyspace) *pb.SrvKeyspace { + result := &pb.SrvKeyspace{ + ShardingColumnName: s.ShardingColumnName, + ShardingColumnType: key.KeyspaceIdTypeToProto(s.ShardingColumnType), + SplitShardCount: s.SplitShardCount, + } + for tt, p := range s.Partitions { + partition := &pb.SrvKeyspace_KeyspacePartition{ + ServedType: TabletTypeToProto(tt), + } + for _, sr := range p.ShardReferences { + partition.ShardReferences = append(partition.ShardReferences, &pb.ShardReference{ + Name: sr.Name, + KeyRange: key.KeyRangeToProto(sr.KeyRange), + }) + } + result.Partitions = append(result.Partitions, partition) + } + for tt, k := range s.ServedFrom { + result.ServedFrom = append(result.ServedFrom, &pb.SrvKeyspace_ServedFrom{ + TabletType: TabletTypeToProto(tt), + Keyspace: k, + }) + } + return result +} + +// ProtoToSrvKeyspace turns a proto to a Tablet +func ProtoToSrvKeyspace(s *pb.SrvKeyspace) *SrvKeyspace { + result := &SrvKeyspace{ + Partitions: make(map[TabletType]*KeyspacePartition), + ShardingColumnName: s.ShardingColumnName, + ShardingColumnType: key.ProtoToKeyspaceIdType(s.ShardingColumnType), + SplitShardCount: s.SplitShardCount, + } + for _, p := range s.Partitions { + tt := ProtoToTabletType(p.ServedType) + partition := &KeyspacePartition{} + for _, sr := range p.ShardReferences { + partition.ShardReferences = append(partition.ShardReferences, ShardReference{ + Name: sr.Name, + KeyRange: key.ProtoToKeyRange(sr.KeyRange), + }) + } + result.Partitions[tt] = partition + } + if len(s.ServedFrom) > 0 { + result.ServedFrom = make(map[TabletType]string) + for _, sf := range s.ServedFrom { + tt := ProtoToTabletType(sf.TabletType) + result.ServedFrom[tt] = sf.Keyspace + } + } + return result +} diff --git a/go/vt/vtgate/fakerpcvtgateconn/conn.go b/go/vt/vtgate/fakerpcvtgateconn/conn.go index aa3687257d..8f25b26ca8 100644 --- a/go/vt/vtgate/fakerpcvtgateconn/conn.go +++ b/go/vt/vtgate/fakerpcvtgateconn/conn.go @@ -278,6 +278,11 @@ func (conn *FakeVTGateConn) SplitQuery(ctx context.Context, keyspace string, que return reply, nil } +// GetSrvKeyspace please see vtgateconn.Impl.SplitQuery +func (conn *FakeVTGateConn) GetSrvKeyspace(ctx context.Context, keyspace string) (*topo.SrvKeyspace, error) { + return nil, fmt.Errorf("NYI") +} + // Close please see vtgateconn.Impl.Close func (conn *FakeVTGateConn) Close() { } diff --git a/go/vt/vtgate/gorpcvtgateconn/conn.go b/go/vt/vtgate/gorpcvtgateconn/conn.go index ea505f36eb..60ae4c1643 100644 --- a/go/vt/vtgate/gorpcvtgateconn/conn.go +++ b/go/vt/vtgate/gorpcvtgateconn/conn.go @@ -366,6 +366,15 @@ func (conn *vtgateConn) SplitQuery(ctx context.Context, keyspace string, query t return result.Splits, nil } +func (conn *vtgateConn) GetSrvKeyspace(ctx context.Context, keyspace string) (*topo.SrvKeyspace, error) { + request := &keyspace + result := &topo.SrvKeyspace{} + if err := conn.rpcConn.Call(ctx, "VTGate.GetSrvKeyspace", request, result); err != nil { + return nil, err + } + return result, nil +} + func (conn *vtgateConn) Close() { conn.rpcConn.Close() } diff --git a/go/vt/vtgate/gorpcvtgateservice/server.go b/go/vt/vtgate/gorpcvtgateservice/server.go index ba7114099c..ed8e1f98fc 100644 --- a/go/vt/vtgate/gorpcvtgateservice/server.go +++ b/go/vt/vtgate/gorpcvtgateservice/server.go @@ -11,6 +11,7 @@ import ( "github.com/youtube/vitess/go/vt/rpc" "github.com/youtube/vitess/go/vt/servenv" + "github.com/youtube/vitess/go/vt/topo" "github.com/youtube/vitess/go/vt/vtgate" "github.com/youtube/vitess/go/vt/vtgate/proto" "github.com/youtube/vitess/go/vt/vtgate/vtgateservice" @@ -230,6 +231,19 @@ func (vtg *VTGate) SplitQuery(ctx context.Context, req *proto.SplitQueryRequest, return vtgErr } +// GetSrvKeyspace is the RPC version of vtgateservice.VTGateService method +func (vtg *VTGate) GetSrvKeyspace(ctx context.Context, keyspace *string, reply *topo.SrvKeyspace) (err error) { + defer vtg.server.HandlePanic(&err) + ctx, cancel := context.WithDeadline(ctx, time.Now().Add(*rpcTimeout)) + defer cancel() + ks, err := vtg.server.GetSrvKeyspace(ctx, *keyspace) + if err != nil { + return err + } + *reply = *ks + return nil +} + // New returns a new VTGate service func New(vtGate vtgateservice.VTGateService) *VTGate { return &VTGate{vtGate} diff --git a/go/vt/vtgate/grpcvtgateconn/conn.go b/go/vt/vtgate/grpcvtgateconn/conn.go index a3bde3637e..8a12b8c72f 100644 --- a/go/vt/vtgate/grpcvtgateconn/conn.go +++ b/go/vt/vtgate/grpcvtgateconn/conn.go @@ -409,6 +409,17 @@ func (conn *vtgateConn) SplitQuery(ctx context.Context, keyspace string, query t return proto.ProtoToSplitQueryParts(response), nil } +func (conn *vtgateConn) GetSrvKeyspace(ctx context.Context, keyspace string) (*topo.SrvKeyspace, error) { + request := &pb.GetSrvKeyspaceRequest{ + Keyspace: keyspace, + } + response, err := conn.c.GetSrvKeyspace(ctx, request) + if err != nil { + return nil, err + } + return topo.ProtoToSrvKeyspace(response.SrvKeyspace), nil +} + func (conn *vtgateConn) Close() { conn.cc.Close() } diff --git a/go/vt/vtgate/grpcvtgateservice/server.go b/go/vt/vtgate/grpcvtgateservice/server.go index 2e22e7ac5f..490c0af95a 100644 --- a/go/vt/vtgate/grpcvtgateservice/server.go +++ b/go/vt/vtgate/grpcvtgateservice/server.go @@ -361,6 +361,18 @@ func (vtg *VTGate) SplitQuery(ctx context.Context, request *pb.SplitQueryRequest return proto.SplitQueryPartsToProto(reply.Splits), nil } +// GetSrvKeyspace is the RPC version of vtgateservice.VTGateService method +func (vtg *VTGate) GetSrvKeyspace(ctx context.Context, request *pb.GetSrvKeyspaceRequest) (response *pb.GetSrvKeyspaceResponse, err error) { + defer vtg.server.HandlePanic(&err) + sk, err := vtg.server.GetSrvKeyspace(ctx, request.Keyspace) + if err != nil { + return nil, err + } + return &pb.GetSrvKeyspaceResponse{ + SrvKeyspace: topo.SrvKeyspaceToProto(sk), + }, nil +} + func init() { vtgate.RegisterVTGates = append(vtgate.RegisterVTGates, func(vtGate vtgateservice.VTGateService) { if servenv.GRPCCheckServiceMap("vtgateservice") { diff --git a/go/vt/vtgate/vtgate.go b/go/vt/vtgate/vtgate.go index 2bb999db0c..9ffc16046c 100644 --- a/go/vt/vtgate/vtgate.go +++ b/go/vt/vtgate/vtgate.go @@ -563,6 +563,11 @@ func (vtg *VTGate) SplitQuery(ctx context.Context, req *proto.SplitQueryRequest, return nil } +// GetSrvKeyspace is part of the vtgate service API. +func (vtg *VTGate) GetSrvKeyspace(ctx context.Context, keyspace string) (*topo.SrvKeyspace, error) { + return vtg.router.serv.GetSrvKeyspace(ctx, vtg.router.cell, keyspace) +} + // Any errors that are caused by VTGate dependencies (e.g, VtTablet) should be logged // as errors in those components, but logged to Info in VTGate itself. func logError(err error, query interface{}, logger *logutil.ThrottledLogger) { diff --git a/go/vt/vtgate/vtgateconn/vtgateconn.go b/go/vt/vtgate/vtgateconn/vtgateconn.go index 41774bd3a3..86d25980ba 100644 --- a/go/vt/vtgate/vtgateconn/vtgateconn.go +++ b/go/vt/vtgate/vtgateconn/vtgateconn.go @@ -166,6 +166,11 @@ func (conn *VTGateConn) SplitQuery(ctx context.Context, keyspace string, query t return conn.impl.SplitQuery(ctx, keyspace, query, splitColumn, splitCount) } +// GetSrvKeyspace returns a topo.SrvKeyspace object. +func (conn *VTGateConn) GetSrvKeyspace(ctx context.Context, keyspace string) (*topo.SrvKeyspace, error) { + return conn.impl.GetSrvKeyspace(ctx, keyspace) +} + // VTGateTx defines an ongoing transaction. // It should not be concurrently used across goroutines. type VTGateTx struct { @@ -348,6 +353,9 @@ type Impl interface { // appending primary key range clauses to the original query. SplitQuery(ctx context.Context, keyspace string, query tproto.BoundQuery, splitColumn string, splitCount int) ([]proto.SplitQueryPart, error) + // GetSrvKeyspace returns a topo.SrvKeyspace. + GetSrvKeyspace(ctx context.Context, keyspace string) (*topo.SrvKeyspace, error) + // Close must be called for releasing resources. Close() } diff --git a/go/vt/vtgate/vtgateconntest/client.go b/go/vt/vtgate/vtgateconntest/client.go index bf5d54e779..6dd4a42000 100644 --- a/go/vt/vtgate/vtgateconntest/client.go +++ b/go/vt/vtgate/vtgateconntest/client.go @@ -375,6 +375,20 @@ func (f *fakeVTGateService) SplitQuery(ctx context.Context, req *proto.SplitQuer return nil } +// GetSrvKeyspace is part of the VTGateService interface +func (f *fakeVTGateService) GetSrvKeyspace(ctx context.Context, keyspace string) (*topo.SrvKeyspace, error) { + if f.hasError { + return nil, testVtGateError + } + if f.panics { + panic(fmt.Errorf("test forced panic")) + } + if keyspace != getSrvKeyspaceKeyspace { + f.t.Errorf("GetSrvKeyspace has wrong input: got %v wanted %v", keyspace, getSrvKeyspaceKeyspace) + } + return getSrvKeyspaceResult, nil +} + // CreateFakeServer returns the fake server for the tests func CreateFakeServer(t *testing.T) vtgateservice.VTGateService { return &fakeVTGateService{ @@ -418,6 +432,7 @@ func TestSuite(t *testing.T, impl vtgateconn.Impl, fakeServer vtgateservice.VTGa testTx2PassNotInTransaction(t, conn) testTx2Fail(t, conn) testSplitQuery(t, conn) + testGetSrvKeyspace(t, conn) // return an error for every call, make sure they're handled properly fakeServer.(*fakeVTGateService).hasError = true @@ -445,6 +460,7 @@ func TestSuite(t *testing.T, impl vtgateconn.Impl, fakeServer vtgateservice.VTGa testCommit2Error(t, conn) testRollback2Error(t, conn) testSplitQueryError(t, conn) + testGetSrvKeyspaceError(t, conn) fakeServer.(*fakeVTGateService).hasError = false // force a panic at every call, then test that works @@ -473,6 +489,7 @@ func TestSuite(t *testing.T, impl vtgateconn.Impl, fakeServer vtgateservice.VTGa testCommit2Panic(t, conn) testRollback2Panic(t, conn) testSplitQueryPanic(t, conn) + testGetSrvKeyspacePanic(t, conn) fakeServer.(*fakeVTGateService).panics = false } @@ -1590,8 +1607,8 @@ func testSplitQuery(t *testing.T, conn *vtgateconn.VTGateConn) { t.Fatalf("SplitQuery failed: %v", err) } if !reflect.DeepEqual(qsl, splitQueryResult.Splits) { - t.Errorf("SplitQuery returned worng result: got %+v wanted %+v", qsl, splitQueryResult.Splits) - t.Errorf("SplitQuery returned worng result: got %+v wanted %+v", qsl[0].Query, splitQueryResult.Splits[0].Query) + t.Errorf("SplitQuery returned wrong result: got %+v wanted %+v", qsl, splitQueryResult.Splits) + t.Errorf("SplitQuery returned wrong result: got %+v wanted %+v", qsl[0].Query, splitQueryResult.Splits[0].Query) } } @@ -1607,6 +1624,29 @@ func testSplitQueryPanic(t *testing.T, conn *vtgateconn.VTGateConn) { expectPanic(t, err) } +func testGetSrvKeyspace(t *testing.T, conn *vtgateconn.VTGateConn) { + ctx := context.Background() + sk, err := conn.GetSrvKeyspace(ctx, getSrvKeyspaceKeyspace) + if err != nil { + t.Fatalf("GetSrvKeyspace failed: %v", err) + } + if !reflect.DeepEqual(sk, getSrvKeyspaceResult) { + t.Errorf("GetSrvKeyspace returned wrong result: got %+v wanted %+v", sk, getSrvKeyspaceResult) + } +} + +func testGetSrvKeyspaceError(t *testing.T, conn *vtgateconn.VTGateConn) { + ctx := context.Background() + _, err := conn.GetSrvKeyspace(ctx, getSrvKeyspaceKeyspace) + verifyError(t, err, "GetSrvKeyspace") +} + +func testGetSrvKeyspacePanic(t *testing.T, conn *vtgateconn.VTGateConn) { + ctx := context.Background() + _, err := conn.GetSrvKeyspace(ctx, getSrvKeyspaceKeyspace) + expectPanic(t, err) +} + var execMap = map[string]struct { execQuery *proto.Query shardQuery *proto.QueryShard @@ -2099,3 +2139,27 @@ var splitQueryResult = &proto.SplitQueryResult{ }, }, } + +var getSrvKeyspaceKeyspace = "test_keyspace" + +var getSrvKeyspaceResult = &topo.SrvKeyspace{ + Partitions: map[topo.TabletType]*topo.KeyspacePartition{ + topo.TYPE_REPLICA: &topo.KeyspacePartition{ + ShardReferences: []topo.ShardReference{ + topo.ShardReference{ + Name: "shard0", + KeyRange: key.KeyRange{ + Start: key.KeyspaceId("s"), + End: key.KeyspaceId("e"), + }, + }, + }, + }, + }, + ShardingColumnName: "sharding_column_name", + ShardingColumnType: key.KIT_UINT64, + ServedFrom: map[topo.TabletType]string{ + topo.TYPE_MASTER: "other_keyspace", + }, + SplitShardCount: 128, +} diff --git a/go/vt/vtgate/vtgateservice/interface.go b/go/vt/vtgate/vtgateservice/interface.go index de461ef51f..521e6c0d56 100644 --- a/go/vt/vtgate/vtgateservice/interface.go +++ b/go/vt/vtgate/vtgateservice/interface.go @@ -7,6 +7,7 @@ package vtgateservice import ( + "github.com/youtube/vitess/go/vt/topo" "github.com/youtube/vitess/go/vt/vtgate/proto" "golang.org/x/net/context" ) @@ -37,6 +38,9 @@ type VTGateService interface { // Map Reduce support SplitQuery(ctx context.Context, req *proto.SplitQueryRequest, reply *proto.SplitQueryResult) error + // Topology support + GetSrvKeyspace(ctx context.Context, keyspace string) (*topo.SrvKeyspace, error) + // HandlePanic should be called with defer at the beginning of each // RPC implementation method, before calling any of the previous methods HandlePanic(err *error) diff --git a/proto/vtgate.proto b/proto/vtgate.proto index afd84f7731..b21cedf47f 100644 --- a/proto/vtgate.proto +++ b/proto/vtgate.proto @@ -293,3 +293,13 @@ message SplitQueryResponse { } repeated Part splits = 1; } + +// GetSrvKeyspaceRequest is the payload to GetSrvKeyspace +message GetSrvKeyspaceRequest { + string keyspace = 1; +} + +// GetSrvKeyspaceResponse is the returned value from GetSrvKeyspace +message GetSrvKeyspaceResponse { + topodata.SrvKeyspace srv_keyspace = 1; +} diff --git a/proto/vtgateservice.proto b/proto/vtgateservice.proto index 411bbcbf12..962128d071 100644 --- a/proto/vtgateservice.proto +++ b/proto/vtgateservice.proto @@ -57,4 +57,13 @@ service Vitess { // Split a query into non-overlapping sub queries rpc SplitQuery(vtgate.SplitQueryRequest) returns (vtgate.SplitQueryResponse) {}; + + // GetSrvKeyspace returns a SrvKeyspace object (as seen by this vtgate). + // This method is provided as a convenient way for clients to take a + // look at the sharding configuration for a Keyspace. Looking at the + // sharding information should not be used for routing queries (as the + // information may change, use the Execute calls for that). + // It is convenient for monitoring applications for instance, or if + // using custom sharding. + rpc GetSrvKeyspace(vtgate.GetSrvKeyspaceRequest) returns (vtgate.GetSrvKeyspaceResponse) {}; } diff --git a/py/vtproto/vtgate_pb2.py b/py/vtproto/vtgate_pb2.py index d114d27a66..2afd045c6d 100644 --- a/py/vtproto/vtgate_pb2.py +++ b/py/vtproto/vtgate_pb2.py @@ -22,7 +22,7 @@ DESCRIPTOR = _descriptor.FileDescriptor( name='vtgate.proto', package='vtgate', syntax='proto3', - serialized_pb=_b('\n\x0cvtgate.proto\x12\x06vtgate\x1a\x0bquery.proto\x1a\x0etopodata.proto\x1a\x0bvtrpc.proto\"\x9e\x01\n\x07Session\x12\x16\n\x0ein_transaction\x18\x01 \x01(\x08\x12\x34\n\x0eshard_sessions\x18\x02 \x03(\x0b\x32\x1c.vtgate.Session.ShardSession\x1a\x45\n\x0cShardSession\x12\x1d\n\x06target\x18\x01 \x01(\x0b\x32\r.query.Target\x12\x16\n\x0etransaction_id\x18\x02 \x01(\x03\"\xbf\x01\n\x0e\x45xecuteRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12 \n\x05query\x18\x03 \x01(\x0b\x32\x11.query.BoundQuery\x12)\n\x0btablet_type\x18\x04 \x01(\x0e\x32\x14.topodata.TabletType\x12\x1a\n\x12not_in_transaction\x18\x05 \x01(\x08\"w\n\x0f\x45xecuteResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12\"\n\x06result\x18\x03 \x01(\x0b\x32\x12.query.QueryResult\"\xe7\x01\n\x14\x45xecuteShardsRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12 \n\x05query\x18\x03 \x01(\x0b\x32\x11.query.BoundQuery\x12\x10\n\x08keyspace\x18\x04 \x01(\t\x12\x0e\n\x06shards\x18\x05 \x03(\t\x12)\n\x0btablet_type\x18\x06 \x01(\x0e\x32\x14.topodata.TabletType\x12\x1a\n\x12not_in_transaction\x18\x07 \x01(\x08\"}\n\x15\x45xecuteShardsResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12\"\n\x06result\x18\x03 \x01(\x0b\x32\x12.query.QueryResult\"\xf2\x01\n\x19\x45xecuteKeyspaceIdsRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12 \n\x05query\x18\x03 \x01(\x0b\x32\x11.query.BoundQuery\x12\x10\n\x08keyspace\x18\x04 \x01(\t\x12\x14\n\x0ckeyspace_ids\x18\x05 \x03(\x0c\x12)\n\x0btablet_type\x18\x06 \x01(\x0e\x32\x14.topodata.TabletType\x12\x1a\n\x12not_in_transaction\x18\x07 \x01(\x08\"\x82\x01\n\x1a\x45xecuteKeyspaceIdsResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12\"\n\x06result\x18\x03 \x01(\x0b\x32\x12.query.QueryResult\"\x82\x02\n\x17\x45xecuteKeyRangesRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12 \n\x05query\x18\x03 \x01(\x0b\x32\x11.query.BoundQuery\x12\x10\n\x08keyspace\x18\x04 \x01(\t\x12&\n\nkey_ranges\x18\x05 \x03(\x0b\x32\x12.topodata.KeyRange\x12)\n\x0btablet_type\x18\x06 \x01(\x0e\x32\x14.topodata.TabletType\x12\x1a\n\x12not_in_transaction\x18\x07 \x01(\x08\"\x80\x01\n\x18\x45xecuteKeyRangesResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12\"\n\x06result\x18\x03 \x01(\x0b\x32\x12.query.QueryResult\"\xbd\x04\n\x17\x45xecuteEntityIdsRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12 \n\x05query\x18\x03 \x01(\x0b\x32\x11.query.BoundQuery\x12\x10\n\x08keyspace\x18\x04 \x01(\t\x12\x1a\n\x12\x65ntity_column_name\x18\x05 \x01(\t\x12\x45\n\x13\x65ntity_keyspace_ids\x18\x06 \x03(\x0b\x32(.vtgate.ExecuteEntityIdsRequest.EntityId\x12)\n\x0btablet_type\x18\x07 \x01(\x0e\x32\x14.topodata.TabletType\x12\x1a\n\x12not_in_transaction\x18\x08 \x01(\x08\x1a\xfd\x01\n\x08\x45ntityId\x12?\n\x08xid_type\x18\x01 \x01(\x0e\x32-.vtgate.ExecuteEntityIdsRequest.EntityId.Type\x12\x11\n\txid_bytes\x18\x02 \x01(\x0c\x12\x0f\n\x07xid_int\x18\x03 \x01(\x03\x12\x10\n\x08xid_uint\x18\x04 \x01(\x04\x12\x11\n\txid_float\x18\x05 \x01(\x01\x12\x13\n\x0bkeyspace_id\x18\x06 \x01(\x0c\"R\n\x04Type\x12\r\n\tTYPE_NULL\x10\x00\x12\x0e\n\nTYPE_BYTES\x10\x01\x12\x0c\n\x08TYPE_INT\x10\x02\x12\r\n\tTYPE_UINT\x10\x03\x12\x0e\n\nTYPE_FLOAT\x10\x04\"\x80\x01\n\x18\x45xecuteEntityIdsResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12\"\n\x06result\x18\x03 \x01(\x0b\x32\x12.query.QueryResult\"U\n\x0f\x42oundShardQuery\x12 \n\x05query\x18\x01 \x01(\x0b\x32\x11.query.BoundQuery\x12\x10\n\x08keyspace\x18\x02 \x01(\t\x12\x0e\n\x06shards\x18\x03 \x03(\t\"\xce\x01\n\x19\x45xecuteBatchShardsRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12(\n\x07queries\x18\x03 \x03(\x0b\x32\x17.vtgate.BoundShardQuery\x12)\n\x0btablet_type\x18\x04 \x01(\x0e\x32\x14.topodata.TabletType\x12\x16\n\x0e\x61s_transaction\x18\x05 \x01(\x08\"\x83\x01\n\x1a\x45xecuteBatchShardsResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12#\n\x07results\x18\x03 \x03(\x0b\x32\x12.query.QueryResult\"`\n\x14\x42oundKeyspaceIdQuery\x12 \n\x05query\x18\x01 \x01(\x0b\x32\x11.query.BoundQuery\x12\x10\n\x08keyspace\x18\x02 \x01(\t\x12\x14\n\x0ckeyspace_ids\x18\x03 \x03(\x0c\"\xd8\x01\n\x1e\x45xecuteBatchKeyspaceIdsRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12-\n\x07queries\x18\x03 \x03(\x0b\x32\x1c.vtgate.BoundKeyspaceIdQuery\x12)\n\x0btablet_type\x18\x04 \x01(\x0e\x32\x14.topodata.TabletType\x12\x16\n\x0e\x61s_transaction\x18\x05 \x01(\x08\"\x88\x01\n\x1f\x45xecuteBatchKeyspaceIdsResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12#\n\x07results\x18\x03 \x03(\x0b\x32\x12.query.QueryResult\"\x87\x01\n\x14StreamExecuteRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x05query\x18\x02 \x01(\x0b\x32\x11.query.BoundQuery\x12)\n\x0btablet_type\x18\x03 \x01(\x0e\x32\x14.topodata.TabletType\"[\n\x15StreamExecuteResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12\"\n\x06result\x18\x02 \x01(\x0b\x32\x12.query.QueryResult\"\xaf\x01\n\x1aStreamExecuteShardsRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x05query\x18\x02 \x01(\x0b\x32\x11.query.BoundQuery\x12\x10\n\x08keyspace\x18\x03 \x01(\t\x12\x0e\n\x06shards\x18\x04 \x03(\t\x12)\n\x0btablet_type\x18\x05 \x01(\x0e\x32\x14.topodata.TabletType\"a\n\x1bStreamExecuteShardsResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12\"\n\x06result\x18\x02 \x01(\x0b\x32\x12.query.QueryResult\"\xba\x01\n\x1fStreamExecuteKeyspaceIdsRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x05query\x18\x02 \x01(\x0b\x32\x11.query.BoundQuery\x12\x10\n\x08keyspace\x18\x03 \x01(\t\x12\x14\n\x0ckeyspace_ids\x18\x04 \x03(\x0c\x12)\n\x0btablet_type\x18\x05 \x01(\x0e\x32\x14.topodata.TabletType\"f\n StreamExecuteKeyspaceIdsResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12\"\n\x06result\x18\x02 \x01(\x0b\x32\x12.query.QueryResult\"\xca\x01\n\x1dStreamExecuteKeyRangesRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x05query\x18\x02 \x01(\x0b\x32\x11.query.BoundQuery\x12\x10\n\x08keyspace\x18\x03 \x01(\t\x12&\n\nkey_ranges\x18\x04 \x03(\x0b\x32\x12.topodata.KeyRange\x12)\n\x0btablet_type\x18\x05 \x01(\x0e\x32\x14.topodata.TabletType\"d\n\x1eStreamExecuteKeyRangesResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12\"\n\x06result\x18\x02 \x01(\x0b\x32\x12.query.QueryResult\"2\n\x0c\x42\x65ginRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\"Q\n\rBeginResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\"U\n\rCommitRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\"0\n\x0e\x43ommitResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\"W\n\x0fRollbackRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\"2\n\x10RollbackResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\"\x96\x01\n\x11SplitQueryRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12\x10\n\x08keyspace\x18\x02 \x01(\t\x12 \n\x05query\x18\x03 \x01(\x0b\x32\x11.query.BoundQuery\x12\x14\n\x0csplit_column\x18\x04 \x01(\t\x12\x13\n\x0bsplit_count\x18\x05 \x01(\x03\"\xf2\x02\n\x12SplitQueryResponse\x12/\n\x06splits\x18\x01 \x03(\x0b\x32\x1f.vtgate.SplitQueryResponse.Part\x1aH\n\x0cKeyRangePart\x12\x10\n\x08keyspace\x18\x01 \x01(\t\x12&\n\nkey_ranges\x18\x02 \x03(\x0b\x32\x12.topodata.KeyRange\x1a-\n\tShardPart\x12\x10\n\x08keyspace\x18\x01 \x01(\t\x12\x0e\n\x06shards\x18\x02 \x03(\t\x1a\xb1\x01\n\x04Part\x12 \n\x05query\x18\x01 \x01(\x0b\x32\x11.query.BoundQuery\x12?\n\x0ekey_range_part\x18\x02 \x01(\x0b\x32\'.vtgate.SplitQueryResponse.KeyRangePart\x12\x38\n\nshard_part\x18\x03 \x01(\x0b\x32$.vtgate.SplitQueryResponse.ShardPart\x12\x0c\n\x04size\x18\x04 \x01(\x03\x62\x06proto3') + serialized_pb=_b('\n\x0cvtgate.proto\x12\x06vtgate\x1a\x0bquery.proto\x1a\x0etopodata.proto\x1a\x0bvtrpc.proto\"\x9e\x01\n\x07Session\x12\x16\n\x0ein_transaction\x18\x01 \x01(\x08\x12\x34\n\x0eshard_sessions\x18\x02 \x03(\x0b\x32\x1c.vtgate.Session.ShardSession\x1a\x45\n\x0cShardSession\x12\x1d\n\x06target\x18\x01 \x01(\x0b\x32\r.query.Target\x12\x16\n\x0etransaction_id\x18\x02 \x01(\x03\"\xbf\x01\n\x0e\x45xecuteRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12 \n\x05query\x18\x03 \x01(\x0b\x32\x11.query.BoundQuery\x12)\n\x0btablet_type\x18\x04 \x01(\x0e\x32\x14.topodata.TabletType\x12\x1a\n\x12not_in_transaction\x18\x05 \x01(\x08\"w\n\x0f\x45xecuteResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12\"\n\x06result\x18\x03 \x01(\x0b\x32\x12.query.QueryResult\"\xe7\x01\n\x14\x45xecuteShardsRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12 \n\x05query\x18\x03 \x01(\x0b\x32\x11.query.BoundQuery\x12\x10\n\x08keyspace\x18\x04 \x01(\t\x12\x0e\n\x06shards\x18\x05 \x03(\t\x12)\n\x0btablet_type\x18\x06 \x01(\x0e\x32\x14.topodata.TabletType\x12\x1a\n\x12not_in_transaction\x18\x07 \x01(\x08\"}\n\x15\x45xecuteShardsResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12\"\n\x06result\x18\x03 \x01(\x0b\x32\x12.query.QueryResult\"\xf2\x01\n\x19\x45xecuteKeyspaceIdsRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12 \n\x05query\x18\x03 \x01(\x0b\x32\x11.query.BoundQuery\x12\x10\n\x08keyspace\x18\x04 \x01(\t\x12\x14\n\x0ckeyspace_ids\x18\x05 \x03(\x0c\x12)\n\x0btablet_type\x18\x06 \x01(\x0e\x32\x14.topodata.TabletType\x12\x1a\n\x12not_in_transaction\x18\x07 \x01(\x08\"\x82\x01\n\x1a\x45xecuteKeyspaceIdsResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12\"\n\x06result\x18\x03 \x01(\x0b\x32\x12.query.QueryResult\"\x82\x02\n\x17\x45xecuteKeyRangesRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12 \n\x05query\x18\x03 \x01(\x0b\x32\x11.query.BoundQuery\x12\x10\n\x08keyspace\x18\x04 \x01(\t\x12&\n\nkey_ranges\x18\x05 \x03(\x0b\x32\x12.topodata.KeyRange\x12)\n\x0btablet_type\x18\x06 \x01(\x0e\x32\x14.topodata.TabletType\x12\x1a\n\x12not_in_transaction\x18\x07 \x01(\x08\"\x80\x01\n\x18\x45xecuteKeyRangesResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12\"\n\x06result\x18\x03 \x01(\x0b\x32\x12.query.QueryResult\"\xbd\x04\n\x17\x45xecuteEntityIdsRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12 \n\x05query\x18\x03 \x01(\x0b\x32\x11.query.BoundQuery\x12\x10\n\x08keyspace\x18\x04 \x01(\t\x12\x1a\n\x12\x65ntity_column_name\x18\x05 \x01(\t\x12\x45\n\x13\x65ntity_keyspace_ids\x18\x06 \x03(\x0b\x32(.vtgate.ExecuteEntityIdsRequest.EntityId\x12)\n\x0btablet_type\x18\x07 \x01(\x0e\x32\x14.topodata.TabletType\x12\x1a\n\x12not_in_transaction\x18\x08 \x01(\x08\x1a\xfd\x01\n\x08\x45ntityId\x12?\n\x08xid_type\x18\x01 \x01(\x0e\x32-.vtgate.ExecuteEntityIdsRequest.EntityId.Type\x12\x11\n\txid_bytes\x18\x02 \x01(\x0c\x12\x0f\n\x07xid_int\x18\x03 \x01(\x03\x12\x10\n\x08xid_uint\x18\x04 \x01(\x04\x12\x11\n\txid_float\x18\x05 \x01(\x01\x12\x13\n\x0bkeyspace_id\x18\x06 \x01(\x0c\"R\n\x04Type\x12\r\n\tTYPE_NULL\x10\x00\x12\x0e\n\nTYPE_BYTES\x10\x01\x12\x0c\n\x08TYPE_INT\x10\x02\x12\r\n\tTYPE_UINT\x10\x03\x12\x0e\n\nTYPE_FLOAT\x10\x04\"\x80\x01\n\x18\x45xecuteEntityIdsResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12\"\n\x06result\x18\x03 \x01(\x0b\x32\x12.query.QueryResult\"U\n\x0f\x42oundShardQuery\x12 \n\x05query\x18\x01 \x01(\x0b\x32\x11.query.BoundQuery\x12\x10\n\x08keyspace\x18\x02 \x01(\t\x12\x0e\n\x06shards\x18\x03 \x03(\t\"\xce\x01\n\x19\x45xecuteBatchShardsRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12(\n\x07queries\x18\x03 \x03(\x0b\x32\x17.vtgate.BoundShardQuery\x12)\n\x0btablet_type\x18\x04 \x01(\x0e\x32\x14.topodata.TabletType\x12\x16\n\x0e\x61s_transaction\x18\x05 \x01(\x08\"\x83\x01\n\x1a\x45xecuteBatchShardsResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12#\n\x07results\x18\x03 \x03(\x0b\x32\x12.query.QueryResult\"`\n\x14\x42oundKeyspaceIdQuery\x12 \n\x05query\x18\x01 \x01(\x0b\x32\x11.query.BoundQuery\x12\x10\n\x08keyspace\x18\x02 \x01(\t\x12\x14\n\x0ckeyspace_ids\x18\x03 \x03(\x0c\"\xd8\x01\n\x1e\x45xecuteBatchKeyspaceIdsRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12-\n\x07queries\x18\x03 \x03(\x0b\x32\x1c.vtgate.BoundKeyspaceIdQuery\x12)\n\x0btablet_type\x18\x04 \x01(\x0e\x32\x14.topodata.TabletType\x12\x16\n\x0e\x61s_transaction\x18\x05 \x01(\x08\"\x88\x01\n\x1f\x45xecuteBatchKeyspaceIdsResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\x12#\n\x07results\x18\x03 \x03(\x0b\x32\x12.query.QueryResult\"\x87\x01\n\x14StreamExecuteRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x05query\x18\x02 \x01(\x0b\x32\x11.query.BoundQuery\x12)\n\x0btablet_type\x18\x03 \x01(\x0e\x32\x14.topodata.TabletType\"[\n\x15StreamExecuteResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12\"\n\x06result\x18\x02 \x01(\x0b\x32\x12.query.QueryResult\"\xaf\x01\n\x1aStreamExecuteShardsRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x05query\x18\x02 \x01(\x0b\x32\x11.query.BoundQuery\x12\x10\n\x08keyspace\x18\x03 \x01(\t\x12\x0e\n\x06shards\x18\x04 \x03(\t\x12)\n\x0btablet_type\x18\x05 \x01(\x0e\x32\x14.topodata.TabletType\"a\n\x1bStreamExecuteShardsResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12\"\n\x06result\x18\x02 \x01(\x0b\x32\x12.query.QueryResult\"\xba\x01\n\x1fStreamExecuteKeyspaceIdsRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x05query\x18\x02 \x01(\x0b\x32\x11.query.BoundQuery\x12\x10\n\x08keyspace\x18\x03 \x01(\t\x12\x14\n\x0ckeyspace_ids\x18\x04 \x03(\x0c\x12)\n\x0btablet_type\x18\x05 \x01(\x0e\x32\x14.topodata.TabletType\"f\n StreamExecuteKeyspaceIdsResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12\"\n\x06result\x18\x02 \x01(\x0b\x32\x12.query.QueryResult\"\xca\x01\n\x1dStreamExecuteKeyRangesRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x05query\x18\x02 \x01(\x0b\x32\x11.query.BoundQuery\x12\x10\n\x08keyspace\x18\x03 \x01(\t\x12&\n\nkey_ranges\x18\x04 \x03(\x0b\x32\x12.topodata.KeyRange\x12)\n\x0btablet_type\x18\x05 \x01(\x0e\x32\x14.topodata.TabletType\"d\n\x1eStreamExecuteKeyRangesResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12\"\n\x06result\x18\x02 \x01(\x0b\x32\x12.query.QueryResult\"2\n\x0c\x42\x65ginRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\"Q\n\rBeginResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\"U\n\rCommitRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\"0\n\x0e\x43ommitResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\"W\n\x0fRollbackRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12 \n\x07session\x18\x02 \x01(\x0b\x32\x0f.vtgate.Session\"2\n\x10RollbackResponse\x12\x1e\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x0f.vtrpc.RPCError\"\x96\x01\n\x11SplitQueryRequest\x12\"\n\tcaller_id\x18\x01 \x01(\x0b\x32\x0f.vtrpc.CallerID\x12\x10\n\x08keyspace\x18\x02 \x01(\t\x12 \n\x05query\x18\x03 \x01(\x0b\x32\x11.query.BoundQuery\x12\x14\n\x0csplit_column\x18\x04 \x01(\t\x12\x13\n\x0bsplit_count\x18\x05 \x01(\x03\"\xf2\x02\n\x12SplitQueryResponse\x12/\n\x06splits\x18\x01 \x03(\x0b\x32\x1f.vtgate.SplitQueryResponse.Part\x1aH\n\x0cKeyRangePart\x12\x10\n\x08keyspace\x18\x01 \x01(\t\x12&\n\nkey_ranges\x18\x02 \x03(\x0b\x32\x12.topodata.KeyRange\x1a-\n\tShardPart\x12\x10\n\x08keyspace\x18\x01 \x01(\t\x12\x0e\n\x06shards\x18\x02 \x03(\t\x1a\xb1\x01\n\x04Part\x12 \n\x05query\x18\x01 \x01(\x0b\x32\x11.query.BoundQuery\x12?\n\x0ekey_range_part\x18\x02 \x01(\x0b\x32\'.vtgate.SplitQueryResponse.KeyRangePart\x12\x38\n\nshard_part\x18\x03 \x01(\x0b\x32$.vtgate.SplitQueryResponse.ShardPart\x12\x0c\n\x04size\x18\x04 \x01(\x03\")\n\x15GetSrvKeyspaceRequest\x12\x10\n\x08keyspace\x18\x01 \x01(\t\"E\n\x16GetSrvKeyspaceResponse\x12+\n\x0csrv_keyspace\x18\x01 \x01(\x0b\x32\x15.topodata.SrvKeyspaceb\x06proto3') , dependencies=[query__pb2.DESCRIPTOR,topodata__pb2.DESCRIPTOR,vtrpc__pb2.DESCRIPTOR,]) _sym_db.RegisterFileDescriptor(DESCRIPTOR) @@ -1881,6 +1881,68 @@ _SPLITQUERYRESPONSE = _descriptor.Descriptor( serialized_end=5311, ) + +_GETSRVKEYSPACEREQUEST = _descriptor.Descriptor( + name='GetSrvKeyspaceRequest', + full_name='vtgate.GetSrvKeyspaceRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='keyspace', full_name='vtgate.GetSrvKeyspaceRequest.keyspace', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=5313, + serialized_end=5354, +) + + +_GETSRVKEYSPACERESPONSE = _descriptor.Descriptor( + name='GetSrvKeyspaceResponse', + full_name='vtgate.GetSrvKeyspaceResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='srv_keyspace', full_name='vtgate.GetSrvKeyspaceResponse.srv_keyspace', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=5356, + serialized_end=5425, +) + _SESSION_SHARDSESSION.fields_by_name['target'].message_type = query__pb2._TARGET _SESSION_SHARDSESSION.containing_type = _SESSION _SESSION.fields_by_name['shard_sessions'].message_type = _SESSION_SHARDSESSION @@ -1980,6 +2042,7 @@ _SPLITQUERYRESPONSE_PART.fields_by_name['key_range_part'].message_type = _SPLITQ _SPLITQUERYRESPONSE_PART.fields_by_name['shard_part'].message_type = _SPLITQUERYRESPONSE_SHARDPART _SPLITQUERYRESPONSE_PART.containing_type = _SPLITQUERYRESPONSE _SPLITQUERYRESPONSE.fields_by_name['splits'].message_type = _SPLITQUERYRESPONSE_PART +_GETSRVKEYSPACERESPONSE.fields_by_name['srv_keyspace'].message_type = topodata__pb2._SRVKEYSPACE DESCRIPTOR.message_types_by_name['Session'] = _SESSION DESCRIPTOR.message_types_by_name['ExecuteRequest'] = _EXECUTEREQUEST DESCRIPTOR.message_types_by_name['ExecuteResponse'] = _EXECUTERESPONSE @@ -2013,6 +2076,8 @@ DESCRIPTOR.message_types_by_name['RollbackRequest'] = _ROLLBACKREQUEST DESCRIPTOR.message_types_by_name['RollbackResponse'] = _ROLLBACKRESPONSE DESCRIPTOR.message_types_by_name['SplitQueryRequest'] = _SPLITQUERYREQUEST DESCRIPTOR.message_types_by_name['SplitQueryResponse'] = _SPLITQUERYRESPONSE +DESCRIPTOR.message_types_by_name['GetSrvKeyspaceRequest'] = _GETSRVKEYSPACEREQUEST +DESCRIPTOR.message_types_by_name['GetSrvKeyspaceResponse'] = _GETSRVKEYSPACERESPONSE Session = _reflection.GeneratedProtocolMessageType('Session', (_message.Message,), dict( @@ -2285,6 +2350,20 @@ _sym_db.RegisterMessage(SplitQueryResponse.KeyRangePart) _sym_db.RegisterMessage(SplitQueryResponse.ShardPart) _sym_db.RegisterMessage(SplitQueryResponse.Part) +GetSrvKeyspaceRequest = _reflection.GeneratedProtocolMessageType('GetSrvKeyspaceRequest', (_message.Message,), dict( + DESCRIPTOR = _GETSRVKEYSPACEREQUEST, + __module__ = 'vtgate_pb2' + # @@protoc_insertion_point(class_scope:vtgate.GetSrvKeyspaceRequest) + )) +_sym_db.RegisterMessage(GetSrvKeyspaceRequest) + +GetSrvKeyspaceResponse = _reflection.GeneratedProtocolMessageType('GetSrvKeyspaceResponse', (_message.Message,), dict( + DESCRIPTOR = _GETSRVKEYSPACERESPONSE, + __module__ = 'vtgate_pb2' + # @@protoc_insertion_point(class_scope:vtgate.GetSrvKeyspaceResponse) + )) +_sym_db.RegisterMessage(GetSrvKeyspaceResponse) + import abc from grpc.early_adopter import implementations diff --git a/py/vtproto/vtgateservice_pb2.py b/py/vtproto/vtgateservice_pb2.py index be50ae849e..4dff6784e7 100644 --- a/py/vtproto/vtgateservice_pb2.py +++ b/py/vtproto/vtgateservice_pb2.py @@ -20,7 +20,7 @@ DESCRIPTOR = _descriptor.FileDescriptor( name='vtgateservice.proto', package='vtgateservice', syntax='proto3', - serialized_pb=_b('\n\x13vtgateservice.proto\x12\rvtgateservice\x1a\x0cvtgate.proto2\x85\n\n\x06Vitess\x12<\n\x07\x45xecute\x12\x16.vtgate.ExecuteRequest\x1a\x17.vtgate.ExecuteResponse\"\x00\x12N\n\rExecuteShards\x12\x1c.vtgate.ExecuteShardsRequest\x1a\x1d.vtgate.ExecuteShardsResponse\"\x00\x12]\n\x12\x45xecuteKeyspaceIds\x12!.vtgate.ExecuteKeyspaceIdsRequest\x1a\".vtgate.ExecuteKeyspaceIdsResponse\"\x00\x12W\n\x10\x45xecuteKeyRanges\x12\x1f.vtgate.ExecuteKeyRangesRequest\x1a .vtgate.ExecuteKeyRangesResponse\"\x00\x12W\n\x10\x45xecuteEntityIds\x12\x1f.vtgate.ExecuteEntityIdsRequest\x1a .vtgate.ExecuteEntityIdsResponse\"\x00\x12]\n\x12\x45xecuteBatchShards\x12!.vtgate.ExecuteBatchShardsRequest\x1a\".vtgate.ExecuteBatchShardsResponse\"\x00\x12l\n\x17\x45xecuteBatchKeyspaceIds\x12&.vtgate.ExecuteBatchKeyspaceIdsRequest\x1a\'.vtgate.ExecuteBatchKeyspaceIdsResponse\"\x00\x12P\n\rStreamExecute\x12\x1c.vtgate.StreamExecuteRequest\x1a\x1d.vtgate.StreamExecuteResponse\"\x00\x30\x01\x12\x62\n\x13StreamExecuteShards\x12\".vtgate.StreamExecuteShardsRequest\x1a#.vtgate.StreamExecuteShardsResponse\"\x00\x30\x01\x12q\n\x18StreamExecuteKeyspaceIds\x12\'.vtgate.StreamExecuteKeyspaceIdsRequest\x1a(.vtgate.StreamExecuteKeyspaceIdsResponse\"\x00\x30\x01\x12k\n\x16StreamExecuteKeyRanges\x12%.vtgate.StreamExecuteKeyRangesRequest\x1a&.vtgate.StreamExecuteKeyRangesResponse\"\x00\x30\x01\x12\x36\n\x05\x42\x65gin\x12\x14.vtgate.BeginRequest\x1a\x15.vtgate.BeginResponse\"\x00\x12\x39\n\x06\x43ommit\x12\x15.vtgate.CommitRequest\x1a\x16.vtgate.CommitResponse\"\x00\x12?\n\x08Rollback\x12\x17.vtgate.RollbackRequest\x1a\x18.vtgate.RollbackResponse\"\x00\x12\x45\n\nSplitQuery\x12\x19.vtgate.SplitQueryRequest\x1a\x1a.vtgate.SplitQueryResponse\"\x00\x62\x06proto3') + serialized_pb=_b('\n\x13vtgateservice.proto\x12\rvtgateservice\x1a\x0cvtgate.proto2\xd8\n\n\x06Vitess\x12<\n\x07\x45xecute\x12\x16.vtgate.ExecuteRequest\x1a\x17.vtgate.ExecuteResponse\"\x00\x12N\n\rExecuteShards\x12\x1c.vtgate.ExecuteShardsRequest\x1a\x1d.vtgate.ExecuteShardsResponse\"\x00\x12]\n\x12\x45xecuteKeyspaceIds\x12!.vtgate.ExecuteKeyspaceIdsRequest\x1a\".vtgate.ExecuteKeyspaceIdsResponse\"\x00\x12W\n\x10\x45xecuteKeyRanges\x12\x1f.vtgate.ExecuteKeyRangesRequest\x1a .vtgate.ExecuteKeyRangesResponse\"\x00\x12W\n\x10\x45xecuteEntityIds\x12\x1f.vtgate.ExecuteEntityIdsRequest\x1a .vtgate.ExecuteEntityIdsResponse\"\x00\x12]\n\x12\x45xecuteBatchShards\x12!.vtgate.ExecuteBatchShardsRequest\x1a\".vtgate.ExecuteBatchShardsResponse\"\x00\x12l\n\x17\x45xecuteBatchKeyspaceIds\x12&.vtgate.ExecuteBatchKeyspaceIdsRequest\x1a\'.vtgate.ExecuteBatchKeyspaceIdsResponse\"\x00\x12P\n\rStreamExecute\x12\x1c.vtgate.StreamExecuteRequest\x1a\x1d.vtgate.StreamExecuteResponse\"\x00\x30\x01\x12\x62\n\x13StreamExecuteShards\x12\".vtgate.StreamExecuteShardsRequest\x1a#.vtgate.StreamExecuteShardsResponse\"\x00\x30\x01\x12q\n\x18StreamExecuteKeyspaceIds\x12\'.vtgate.StreamExecuteKeyspaceIdsRequest\x1a(.vtgate.StreamExecuteKeyspaceIdsResponse\"\x00\x30\x01\x12k\n\x16StreamExecuteKeyRanges\x12%.vtgate.StreamExecuteKeyRangesRequest\x1a&.vtgate.StreamExecuteKeyRangesResponse\"\x00\x30\x01\x12\x36\n\x05\x42\x65gin\x12\x14.vtgate.BeginRequest\x1a\x15.vtgate.BeginResponse\"\x00\x12\x39\n\x06\x43ommit\x12\x15.vtgate.CommitRequest\x1a\x16.vtgate.CommitResponse\"\x00\x12?\n\x08Rollback\x12\x17.vtgate.RollbackRequest\x1a\x18.vtgate.RollbackResponse\"\x00\x12\x45\n\nSplitQuery\x12\x19.vtgate.SplitQueryRequest\x1a\x1a.vtgate.SplitQueryResponse\"\x00\x12Q\n\x0eGetSrvKeyspace\x12\x1d.vtgate.GetSrvKeyspaceRequest\x1a\x1e.vtgate.GetSrvKeyspaceResponse\"\x00\x62\x06proto3') , dependencies=[vtgate__pb2.DESCRIPTOR,]) _sym_db.RegisterFileDescriptor(DESCRIPTOR) @@ -80,6 +80,9 @@ class EarlyAdopterVitessServicer(object): @abc.abstractmethod def SplitQuery(self, request, context): raise NotImplementedError() + @abc.abstractmethod + def GetSrvKeyspace(self, request, context): + raise NotImplementedError() class EarlyAdopterVitessServer(object): """""" __metaclass__ = abc.ABCMeta @@ -152,6 +155,10 @@ class EarlyAdopterVitessStub(object): def SplitQuery(self, request): raise NotImplementedError() SplitQuery.async = None + @abc.abstractmethod + def GetSrvKeyspace(self, request): + raise NotImplementedError() + GetSrvKeyspace.async = None def early_adopter_create_Vitess_server(servicer, port, private_key=None, certificate_chain=None): import vtgate_pb2 import vtgate_pb2 @@ -183,6 +190,8 @@ def early_adopter_create_Vitess_server(servicer, port, private_key=None, certifi import vtgate_pb2 import vtgate_pb2 import vtgate_pb2 + import vtgate_pb2 + import vtgate_pb2 method_service_descriptions = { "Begin": utilities.unary_unary_service_description( servicer.Begin, @@ -229,6 +238,11 @@ def early_adopter_create_Vitess_server(servicer, port, private_key=None, certifi vtgate_pb2.ExecuteShardsRequest.FromString, vtgate_pb2.ExecuteShardsResponse.SerializeToString, ), + "GetSrvKeyspace": utilities.unary_unary_service_description( + servicer.GetSrvKeyspace, + vtgate_pb2.GetSrvKeyspaceRequest.FromString, + vtgate_pb2.GetSrvKeyspaceResponse.SerializeToString, + ), "Rollback": utilities.unary_unary_service_description( servicer.Rollback, vtgate_pb2.RollbackRequest.FromString, @@ -292,6 +306,8 @@ def early_adopter_create_Vitess_stub(host, port, metadata_transformer=None, secu import vtgate_pb2 import vtgate_pb2 import vtgate_pb2 + import vtgate_pb2 + import vtgate_pb2 method_invocation_descriptions = { "Begin": utilities.unary_unary_invocation_description( vtgate_pb2.BeginRequest.SerializeToString, @@ -329,6 +345,10 @@ def early_adopter_create_Vitess_stub(host, port, metadata_transformer=None, secu vtgate_pb2.ExecuteShardsRequest.SerializeToString, vtgate_pb2.ExecuteShardsResponse.FromString, ), + "GetSrvKeyspace": utilities.unary_unary_invocation_description( + vtgate_pb2.GetSrvKeyspaceRequest.SerializeToString, + vtgate_pb2.GetSrvKeyspaceResponse.FromString, + ), "Rollback": utilities.unary_unary_invocation_description( vtgate_pb2.RollbackRequest.SerializeToString, vtgate_pb2.RollbackResponse.FromString,