Implement FindAllShardsInKeyspace

Signed-off-by: Andrew Mason <amason@slack-corp.com>
This commit is contained in:
Andrew Mason 2020-12-08 16:24:57 -05:00
Родитель ad94b672ef
Коммит 196245227d
8 изменённых файлов: 338 добавлений и 43 удалений

Просмотреть файл

@ -1,6 +1,7 @@
package main
import (
"encoding/json"
"fmt"
"github.com/spf13/cobra"
@ -9,6 +10,12 @@ import (
)
var (
findAllShardsInKeyspaceCmd = &cobra.Command{
Use: "FindAllShardsInKeyspace keyspace",
Aliases: []string{"findallshardsinkeyspace"},
Args: cobra.ExactArgs(1),
RunE: commandFindAllShardsInKeyspace,
}
getKeyspaceCmd = &cobra.Command{
Use: "GetKeyspace keyspace",
Aliases: []string{"getkeyspace"},
@ -23,6 +30,25 @@ var (
}
)
func commandFindAllShardsInKeyspace(cmd *cobra.Command, args []string) error {
ks := cmd.Flags().Arg(0)
resp, err := client.FindAllShardsInKeyspace(commandCtx, &vtctldatapb.FindAllShardsInKeyspaceRequest{
Keyspace: ks,
})
if err != nil {
return err
}
data, err := json.Marshal(&resp)
if err != nil {
return err
}
fmt.Printf("%s\n", data)
return nil
}
func commandGetKeyspace(cmd *cobra.Command, args []string) error {
ks := cmd.Flags().Arg(0)
resp, err := client.GetKeyspace(commandCtx, &vtctldatapb.GetKeyspaceRequest{
@ -48,6 +74,7 @@ func commandGetKeyspaces(cmd *cobra.Command, args []string) error {
}
func init() {
rootCmd.AddCommand(findAllShardsInKeyspaceCmd)
rootCmd.AddCommand(getKeyspaceCmd)
rootCmd.AddCommand(getKeyspacesCmd)
}

Просмотреть файл

@ -268,6 +268,139 @@ func (m *Keyspace) GetKeyspace() *topodata.Keyspace {
return nil
}
type FindAllShardsInKeyspaceRequest struct {
Keyspace string `protobuf:"bytes,1,opt,name=keyspace,proto3" json:"keyspace,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *FindAllShardsInKeyspaceRequest) Reset() { *m = FindAllShardsInKeyspaceRequest{} }
func (m *FindAllShardsInKeyspaceRequest) String() string { return proto.CompactTextString(m) }
func (*FindAllShardsInKeyspaceRequest) ProtoMessage() {}
func (*FindAllShardsInKeyspaceRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_f41247b323a1ab2e, []int{6}
}
func (m *FindAllShardsInKeyspaceRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_FindAllShardsInKeyspaceRequest.Unmarshal(m, b)
}
func (m *FindAllShardsInKeyspaceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_FindAllShardsInKeyspaceRequest.Marshal(b, m, deterministic)
}
func (m *FindAllShardsInKeyspaceRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_FindAllShardsInKeyspaceRequest.Merge(m, src)
}
func (m *FindAllShardsInKeyspaceRequest) XXX_Size() int {
return xxx_messageInfo_FindAllShardsInKeyspaceRequest.Size(m)
}
func (m *FindAllShardsInKeyspaceRequest) XXX_DiscardUnknown() {
xxx_messageInfo_FindAllShardsInKeyspaceRequest.DiscardUnknown(m)
}
var xxx_messageInfo_FindAllShardsInKeyspaceRequest proto.InternalMessageInfo
func (m *FindAllShardsInKeyspaceRequest) GetKeyspace() string {
if m != nil {
return m.Keyspace
}
return ""
}
type FindAllShardsInKeyspaceResponse struct {
Shards map[string]*Shard `protobuf:"bytes,1,rep,name=shards,proto3" json:"shards,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *FindAllShardsInKeyspaceResponse) Reset() { *m = FindAllShardsInKeyspaceResponse{} }
func (m *FindAllShardsInKeyspaceResponse) String() string { return proto.CompactTextString(m) }
func (*FindAllShardsInKeyspaceResponse) ProtoMessage() {}
func (*FindAllShardsInKeyspaceResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_f41247b323a1ab2e, []int{7}
}
func (m *FindAllShardsInKeyspaceResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_FindAllShardsInKeyspaceResponse.Unmarshal(m, b)
}
func (m *FindAllShardsInKeyspaceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_FindAllShardsInKeyspaceResponse.Marshal(b, m, deterministic)
}
func (m *FindAllShardsInKeyspaceResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_FindAllShardsInKeyspaceResponse.Merge(m, src)
}
func (m *FindAllShardsInKeyspaceResponse) XXX_Size() int {
return xxx_messageInfo_FindAllShardsInKeyspaceResponse.Size(m)
}
func (m *FindAllShardsInKeyspaceResponse) XXX_DiscardUnknown() {
xxx_messageInfo_FindAllShardsInKeyspaceResponse.DiscardUnknown(m)
}
var xxx_messageInfo_FindAllShardsInKeyspaceResponse proto.InternalMessageInfo
func (m *FindAllShardsInKeyspaceResponse) GetShards() map[string]*Shard {
if m != nil {
return m.Shards
}
return nil
}
type Shard struct {
Keyspace string `protobuf:"bytes,1,opt,name=keyspace,proto3" json:"keyspace,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
Shard *topodata.Shard `protobuf:"bytes,3,opt,name=shard,proto3" json:"shard,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Shard) Reset() { *m = Shard{} }
func (m *Shard) String() string { return proto.CompactTextString(m) }
func (*Shard) ProtoMessage() {}
func (*Shard) Descriptor() ([]byte, []int) {
return fileDescriptor_f41247b323a1ab2e, []int{8}
}
func (m *Shard) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Shard.Unmarshal(m, b)
}
func (m *Shard) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Shard.Marshal(b, m, deterministic)
}
func (m *Shard) XXX_Merge(src proto.Message) {
xxx_messageInfo_Shard.Merge(m, src)
}
func (m *Shard) XXX_Size() int {
return xxx_messageInfo_Shard.Size(m)
}
func (m *Shard) XXX_DiscardUnknown() {
xxx_messageInfo_Shard.DiscardUnknown(m)
}
var xxx_messageInfo_Shard proto.InternalMessageInfo
func (m *Shard) GetKeyspace() string {
if m != nil {
return m.Keyspace
}
return ""
}
func (m *Shard) GetName() string {
if m != nil {
return m.Name
}
return ""
}
func (m *Shard) GetShard() *topodata.Shard {
if m != nil {
return m.Shard
}
return nil
}
// TableMaterializeSttings contains the settings for one table.
type TableMaterializeSettings struct {
TargetTable string `protobuf:"bytes,1,opt,name=target_table,json=targetTable,proto3" json:"target_table,omitempty"`
@ -286,7 +419,7 @@ func (m *TableMaterializeSettings) Reset() { *m = TableMaterializeSettin
func (m *TableMaterializeSettings) String() string { return proto.CompactTextString(m) }
func (*TableMaterializeSettings) ProtoMessage() {}
func (*TableMaterializeSettings) Descriptor() ([]byte, []int) {
return fileDescriptor_f41247b323a1ab2e, []int{6}
return fileDescriptor_f41247b323a1ab2e, []int{9}
}
func (m *TableMaterializeSettings) XXX_Unmarshal(b []byte) error {
@ -349,7 +482,7 @@ func (m *MaterializeSettings) Reset() { *m = MaterializeSettings{} }
func (m *MaterializeSettings) String() string { return proto.CompactTextString(m) }
func (*MaterializeSettings) ProtoMessage() {}
func (*MaterializeSettings) Descriptor() ([]byte, []int) {
return fileDescriptor_f41247b323a1ab2e, []int{7}
return fileDescriptor_f41247b323a1ab2e, []int{10}
}
func (m *MaterializeSettings) XXX_Unmarshal(b []byte) error {
@ -426,6 +559,10 @@ func init() {
proto.RegisterType((*GetKeyspacesResponse)(nil), "vtctldata.GetKeyspacesResponse")
proto.RegisterType((*GetKeyspaceRequest)(nil), "vtctldata.GetKeyspaceRequest")
proto.RegisterType((*Keyspace)(nil), "vtctldata.Keyspace")
proto.RegisterType((*FindAllShardsInKeyspaceRequest)(nil), "vtctldata.FindAllShardsInKeyspaceRequest")
proto.RegisterType((*FindAllShardsInKeyspaceResponse)(nil), "vtctldata.FindAllShardsInKeyspaceResponse")
proto.RegisterMapType((map[string]*Shard)(nil), "vtctldata.FindAllShardsInKeyspaceResponse.ShardsEntry")
proto.RegisterType((*Shard)(nil), "vtctldata.Shard")
proto.RegisterType((*TableMaterializeSettings)(nil), "vtctldata.TableMaterializeSettings")
proto.RegisterType((*MaterializeSettings)(nil), "vtctldata.MaterializeSettings")
}
@ -433,37 +570,44 @@ func init() {
func init() { proto.RegisterFile("vtctldata.proto", fileDescriptor_f41247b323a1ab2e) }
var fileDescriptor_f41247b323a1ab2e = []byte{
// 505 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0xd1, 0x8e, 0xd3, 0x3c,
0x10, 0x85, 0x95, 0xb6, 0xbb, 0x7f, 0x33, 0xfd, 0x9b, 0x82, 0x0b, 0x52, 0x54, 0x84, 0x54, 0x02,
0xec, 0x56, 0x42, 0x4a, 0x61, 0x79, 0x02, 0x28, 0x15, 0x02, 0x04, 0x17, 0xa1, 0x02, 0x89, 0x9b,
0xc8, 0x4d, 0x67, 0xab, 0x68, 0xdd, 0x38, 0xc4, 0xd3, 0xee, 0x96, 0x37, 0xe0, 0x65, 0x78, 0x46,
0x14, 0x3b, 0x76, 0xbb, 0xd2, 0x72, 0xe7, 0x7c, 0x3e, 0x33, 0x73, 0xe6, 0x58, 0x81, 0xc1, 0x8e,
0x32, 0x12, 0x2b, 0x4e, 0x3c, 0x2e, 0x2b, 0x49, 0x92, 0xf9, 0x0e, 0x8c, 0xfa, 0x42, 0xae, 0xb7,
0x94, 0x0b, 0x73, 0x33, 0x0a, 0x48, 0x96, 0xf2, 0xa0, 0x8c, 0xbe, 0xc3, 0x68, 0x7e, 0x83, 0xd9,
0x96, 0xf0, 0x5b, 0x5d, 0x32, 0x93, 0x9b, 0x0d, 0x2f, 0x56, 0x09, 0xfe, 0xdc, 0xa2, 0x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 0x00, 0x00, 0xff,
0xff, 0xd5, 0x06, 0x15, 0x84, 0xac, 0x03, 0x00, 0x00,
// 620 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xdf, 0x6e, 0xd3, 0x4a,
0x10, 0xc6, 0xe5, 0xa4, 0xe9, 0x89, 0x27, 0x27, 0x49, 0xcf, 0xf6, 0x20, 0x59, 0x41, 0x40, 0x30,
0xb4, 0x8d, 0x84, 0xe4, 0x40, 0x91, 0x10, 0x42, 0xdc, 0x94, 0x12, 0x50, 0xa9, 0xe8, 0x85, 0x5b,
0x81, 0xc4, 0x05, 0xd6, 0xd6, 0x9e, 0x06, 0xab, 0x1b, 0xaf, 0xf1, 0x4e, 0xd2, 0x86, 0x37, 0xe0,
0x65, 0x78, 0x04, 0x9e, 0x0d, 0x79, 0xd7, 0x76, 0x5c, 0xa9, 0x05, 0x71, 0x37, 0xf9, 0xcd, 0xbf,
0x6f, 0x3e, 0xaf, 0x02, 0xfd, 0x05, 0x85, 0x24, 0x22, 0x4e, 0xdc, 0x4b, 0x33, 0x49, 0x92, 0xd9,
0x15, 0x18, 0x74, 0x85, 0x9c, 0xce, 0x29, 0x16, 0x26, 0x33, 0xe8, 0x91, 0x4c, 0xe5, 0xaa, 0xd2,
0xfd, 0x08, 0x83, 0xc9, 0x25, 0x86, 0x73, 0xc2, 0x0f, 0x79, 0xcb, 0xbe, 0x9c, 0xcd, 0x78, 0x12,
0xf9, 0xf8, 0x75, 0x8e, 0x8a, 0x18, 0x83, 0x35, 0x9e, 0x4d, 0x95, 0x63, 0x0d, 0x9b, 0x23, 0xdb,
0xd7, 0x31, 0xdb, 0x82, 0x1e, 0x0f, 0x29, 0x96, 0x49, 0x40, 0xf1, 0x0c, 0xe5, 0x9c, 0x9c, 0xc6,
0xd0, 0x1a, 0x35, 0xfd, 0xae, 0xa1, 0x27, 0x06, 0xba, 0xfb, 0x70, 0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d3, 0xd2, 0xcf, 0xe7, 0x41, 0xed, 0x73,
0xde, 0xe4, 0xac, 0xdf, 0xd5, 0xad, 0xd5, 0x85, 0x0c, 0xd6, 0x42, 0x14, 0xc2, 0x59, 0x37, 0x1f,
0x30, 0x8f, 0x8d, 0xf9, 0xa7, 0x22, 0x37, 0x7f, 0x99, 0xa2, 0x72, 0xfe, 0x29, 0xcd, 0xcf, 0xd9,
0x49, 0x8e, 0x5e, 0x8d, 0x3e, 0x6d, 0x2f, 0x62, 0x42, 0xa5, 0xbc, 0x58, 0x8e, 0x4d, 0x34, 0x9e,
0xca, 0xf1, 0x82, 0xc6, 0xfa, 0xdf, 0x6b, 0x5c, 0x09, 0x39, 0x5d, 0xd7, 0xe0, 0xe9, 0xaf, 0x00,
0x00, 0x00, 0xff, 0xff, 0x25, 0x63, 0x6b, 0x01, 0x0b, 0x05, 0x00, 0x00,
}

Просмотреть файл

@ -29,20 +29,22 @@ const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
func init() { proto.RegisterFile("vtctlservice.proto", fileDescriptor_27055cdbb1148d2b) }
var fileDescriptor_27055cdbb1148d2b = []byte{
// 204 bytes of a gzipped FileDescriptorProto
// 239 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2a, 0x2b, 0x49, 0x2e,
0xc9, 0x29, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c, 0x4e, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2,
0x41, 0x16, 0x93, 0xe2, 0x07, 0xf3, 0x52, 0x12, 0x4b, 0x12, 0x21, 0xd2, 0x46, 0x85, 0x5c, 0xac,
0x61, 0x20, 0x21, 0xa1, 0x0c, 0x2e, 0x61, 0xd7, 0x8a, 0xd4, 0xe4, 0xd2, 0x92, 0x54, 0x30, 0xdf,
0x39, 0x3f, 0x37, 0x37, 0x31, 0x2f, 0x45, 0x48, 0x55, 0x0f, 0xa1, 0x03, 0x8b, 0x7c, 0x50, 0x6a,
0x61, 0x69, 0x6a, 0x71, 0x89, 0x94, 0x1a, 0x21, 0x65, 0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, 0x4a,
0x0c, 0x06, 0x8c, 0x46, 0x0b, 0x18, 0xb9, 0xd8, 0xc0, 0x92, 0x29, 0x42, 0xce, 0x5c, 0xdc, 0xee,
0xa9, 0x25, 0xde, 0xa9, 0x95, 0xc5, 0x05, 0x89, 0xc9, 0xa9, 0x42, 0xb2, 0x48, 0xa6, 0x20, 0x89,
0xc3, 0x2c, 0x11, 0x46, 0x92, 0x86, 0xc9, 0x29, 0x31, 0x08, 0x05, 0x72, 0xf1, 0x20, 0x29, 0x2e,
0x16, 0x92, 0xc3, 0x6e, 0x4a, 0x31, 0xcc, 0x18, 0x79, 0x9c, 0xf2, 0x30, 0x47, 0x3a, 0x69, 0x47,
0x69, 0x96, 0x65, 0x96, 0xa4, 0x16, 0x17, 0xeb, 0x65, 0xe6, 0xeb, 0x43, 0x58, 0xfa, 0xe9, 0xf9,
0xfa, 0x65, 0x25, 0xfa, 0xe0, 0x50, 0xd3, 0x47, 0x0e, 0xd3, 0x24, 0x36, 0xb0, 0x98, 0x31, 0x20,
0x00, 0x00, 0xff, 0xff, 0x6a, 0xd1, 0x88, 0x6e, 0x7e, 0x01, 0x00, 0x00,
0x0c, 0x06, 0x8c, 0x46, 0x53, 0x98, 0xb8, 0xd8, 0xc0, 0x92, 0x29, 0x42, 0x45, 0x5c, 0xe2, 0x6e,
0x99, 0x79, 0x29, 0x8e, 0x39, 0x39, 0xc1, 0x19, 0x89, 0x45, 0x29, 0xc5, 0x9e, 0x79, 0xde, 0xa9,
0x95, 0xc5, 0x05, 0x89, 0xc9, 0xa9, 0x42, 0x9a, 0x48, 0x26, 0xe2, 0x50, 0x03, 0xb3, 0x5c, 0x8b,
0x18, 0xa5, 0x30, 0x07, 0x08, 0x39, 0x73, 0x71, 0xbb, 0xa7, 0x96, 0xc0, 0xed, 0x91, 0x45, 0xd2,
0x8c, 0x24, 0x0e, 0x33, 0x5b, 0x18, 0x49, 0x1a, 0x26, 0xa7, 0xc4, 0x20, 0x14, 0xc8, 0xc5, 0x83,
0xa4, 0xb8, 0x58, 0x48, 0x0e, 0xbb, 0x29, 0xc5, 0x30, 0x63, 0xe4, 0x71, 0xca, 0xc3, 0xdc, 0xe5,
0xa4, 0x1d, 0xa5, 0x59, 0x96, 0x59, 0x92, 0x5a, 0x5c, 0xac, 0x97, 0x99, 0xaf, 0x0f, 0x61, 0xe9,
0xa7, 0xe7, 0xeb, 0x97, 0x95, 0xe8, 0x83, 0x63, 0x4a, 0x1f, 0x39, 0x1e, 0x93, 0xd8, 0xc0, 0x62,
0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa6, 0x9d, 0x46, 0x8d, 0xf2, 0x01, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@ -156,6 +158,8 @@ var _Vtctl_serviceDesc = grpc.ServiceDesc{
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type VtctldClient interface {
// FindAllShardsInKeyspace returns a map of shard names to shard references for a given keyspace.
FindAllShardsInKeyspace(ctx context.Context, in *vtctldata.FindAllShardsInKeyspaceRequest, opts ...grpc.CallOption) (*vtctldata.FindAllShardsInKeyspaceResponse, error)
// GetKeyspace reads the given keyspace from the topo and returns it.
GetKeyspace(ctx context.Context, in *vtctldata.GetKeyspaceRequest, opts ...grpc.CallOption) (*vtctldata.Keyspace, error)
// GetKeyspaces returns the keyspace struct of all keyspaces in the topo.
@ -170,6 +174,15 @@ func NewVtctldClient(cc *grpc.ClientConn) VtctldClient {
return &vtctldClient{cc}
}
func (c *vtctldClient) FindAllShardsInKeyspace(ctx context.Context, in *vtctldata.FindAllShardsInKeyspaceRequest, opts ...grpc.CallOption) (*vtctldata.FindAllShardsInKeyspaceResponse, error) {
out := new(vtctldata.FindAllShardsInKeyspaceResponse)
err := c.cc.Invoke(ctx, "/vtctlservice.Vtctld/FindAllShardsInKeyspace", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *vtctldClient) GetKeyspace(ctx context.Context, in *vtctldata.GetKeyspaceRequest, opts ...grpc.CallOption) (*vtctldata.Keyspace, error) {
out := new(vtctldata.Keyspace)
err := c.cc.Invoke(ctx, "/vtctlservice.Vtctld/GetKeyspace", in, out, opts...)
@ -190,6 +203,8 @@ func (c *vtctldClient) GetKeyspaces(ctx context.Context, in *vtctldata.GetKeyspa
// VtctldServer is the server API for Vtctld service.
type VtctldServer interface {
// FindAllShardsInKeyspace returns a map of shard names to shard references for a given keyspace.
FindAllShardsInKeyspace(context.Context, *vtctldata.FindAllShardsInKeyspaceRequest) (*vtctldata.FindAllShardsInKeyspaceResponse, error)
// GetKeyspace reads the given keyspace from the topo and returns it.
GetKeyspace(context.Context, *vtctldata.GetKeyspaceRequest) (*vtctldata.Keyspace, error)
// GetKeyspaces returns the keyspace struct of all keyspaces in the topo.
@ -200,6 +215,9 @@ type VtctldServer interface {
type UnimplementedVtctldServer struct {
}
func (*UnimplementedVtctldServer) FindAllShardsInKeyspace(ctx context.Context, req *vtctldata.FindAllShardsInKeyspaceRequest) (*vtctldata.FindAllShardsInKeyspaceResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method FindAllShardsInKeyspace not implemented")
}
func (*UnimplementedVtctldServer) GetKeyspace(ctx context.Context, req *vtctldata.GetKeyspaceRequest) (*vtctldata.Keyspace, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetKeyspace not implemented")
}
@ -211,6 +229,24 @@ func RegisterVtctldServer(s *grpc.Server, srv VtctldServer) {
s.RegisterService(&_Vtctld_serviceDesc, srv)
}
func _Vtctld_FindAllShardsInKeyspace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(vtctldata.FindAllShardsInKeyspaceRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(VtctldServer).FindAllShardsInKeyspace(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/vtctlservice.Vtctld/FindAllShardsInKeyspace",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(VtctldServer).FindAllShardsInKeyspace(ctx, req.(*vtctldata.FindAllShardsInKeyspaceRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Vtctld_GetKeyspace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(vtctldata.GetKeyspaceRequest)
if err := dec(in); err != nil {
@ -251,6 +287,10 @@ var _Vtctld_serviceDesc = grpc.ServiceDesc{
ServiceName: "vtctlservice.Vtctld",
HandlerType: (*VtctldServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "FindAllShardsInKeyspace",
Handler: _Vtctld_FindAllShardsInKeyspace_Handler,
},
{
MethodName: "GetKeyspace",
Handler: _Vtctld_GetKeyspace_Handler,

Просмотреть файл

@ -69,6 +69,14 @@ func (client *gRPCVtctldClient) Close() error {
// (TODO:@amason) - This boilerplate should end up the same for all ~70 commands
// .... we should do this with code gen.
func (client *gRPCVtctldClient) FindAllShardsInKeyspace(ctx context.Context, in *vtctldatapb.FindAllShardsInKeyspaceRequest, opts ...grpc.CallOption) (*vtctldatapb.FindAllShardsInKeyspaceResponse, error) {
if client.c == nil {
return nil, status.Error(codes.Unavailable, connClosedMsg)
}
return client.c.FindAllShardsInKeyspace(ctx, in, opts...)
}
func (client *gRPCVtctldClient) GetKeyspace(ctx context.Context, in *vtctldatapb.GetKeyspaceRequest, opts ...grpc.CallOption) (*vtctldatapb.Keyspace, error) {
if client.c == nil {
return nil, status.Error(codes.Unavailable, connClosedMsg)

Просмотреть файл

@ -20,6 +20,27 @@ func NewVtctldServer(ts *topo.Server) *VtctldServer {
return &VtctldServer{ts: ts}
}
// FindAllShardsInKeyspace is part of the vtctlservicepb.VtctldServer interface.
func (s *VtctldServer) FindAllShardsInKeyspace(ctx context.Context, req *vtctldatapb.FindAllShardsInKeyspaceRequest) (*vtctldatapb.FindAllShardsInKeyspaceResponse, error) {
result, err := s.ts.FindAllShardsInKeyspace(ctx, req.Keyspace)
if err != nil {
return nil, err
}
shards := map[string]*vtctldatapb.Shard{}
for _, shard := range result {
shards[shard.ShardName()] = &vtctldatapb.Shard{
Keyspace: req.Keyspace,
Name: shard.ShardName(),
Shard: shard.Shard,
}
}
return &vtctldatapb.FindAllShardsInKeyspaceResponse{
Shards: shards,
}, nil
}
// GetKeyspace is part of the vtctlservicepb.VtctldServer interface.
func (s *VtctldServer) GetKeyspace(ctx context.Context, req *vtctldatapb.GetKeyspaceRequest) (*vtctldatapb.Keyspace, error) {
keyspace, err := s.ts.GetKeyspace(ctx, req.Keyspace)

Просмотреть файл

@ -14,6 +14,45 @@ import (
vtctldatapb "vitess.io/vitess/go/vt/proto/vtctldata"
)
func TestFindAllShardsInKeyspace(t *testing.T) {
ctx := context.Background()
ts := memorytopo.NewServer("cell1")
vtctld := NewVtctldServer(ts)
ks := &vtctldatapb.Keyspace{
Name: "testkeyspace",
Keyspace: &topodatapb.Keyspace{},
}
addKeyspace(ctx, t, ts, ks)
si1, err := ts.GetOrCreateShard(ctx, ks.Name, "-80")
require.NoError(t, err)
si2, err := ts.GetOrCreateShard(ctx, ks.Name, "80-")
require.NoError(t, err)
resp, err := vtctld.FindAllShardsInKeyspace(ctx, &vtctldatapb.FindAllShardsInKeyspaceRequest{Keyspace: ks.Name})
assert.NoError(t, err)
assert.NotNil(t, resp)
expected := map[string]*vtctldatapb.Shard{
"-80": {
Keyspace: ks.Name,
Name: "-80",
Shard: si1.Shard,
},
"80-": {
Keyspace: ks.Name,
Name: "80-",
Shard: si2.Shard,
},
}
assert.Equal(t, expected, resp.Shards)
_, err = vtctld.FindAllShardsInKeyspace(ctx, &vtctldatapb.FindAllShardsInKeyspaceRequest{Keyspace: "nothing"})
assert.Error(t, err)
}
func TestGetKeyspace(t *testing.T) {
ctx := context.Background()
ts := memorytopo.NewServer("cell1")

Просмотреть файл

@ -53,6 +53,20 @@ message Keyspace {
topodata.Keyspace keyspace = 2;
}
message FindAllShardsInKeyspaceRequest {
string keyspace = 1;
}
message FindAllShardsInKeyspaceResponse {
map<string, Shard> shards = 1;
}
message Shard {
string keyspace = 1;
string name = 2;
topodata.Shard shard = 3;
}
// TableMaterializeSttings contains the settings for one table.
message TableMaterializeSettings {
string target_table = 1;

Просмотреть файл

@ -31,6 +31,8 @@ service Vtctl {
// Service Vtctld exposes gRPC endpoints for each vt command.
service Vtctld {
// FindAllShardsInKeyspace returns a map of shard names to shard references for a given keyspace.
rpc FindAllShardsInKeyspace(vtctldata.FindAllShardsInKeyspaceRequest) returns (vtctldata.FindAllShardsInKeyspaceResponse) {};
// GetKeyspace reads the given keyspace from the topo and returns it.
rpc GetKeyspace(vtctldata.GetKeyspaceRequest) returns (vtctldata.Keyspace) {};
// GetKeyspaces returns the keyspace struct of all keyspaces in the topo.