Replace keyspace_type in vschema with a boolean require_explicit_routing

Signed-off-by: deepthi <deepthi@planetscale.com>
This commit is contained in:
deepthi 2019-10-06 12:23:42 -07:00
Родитель cbbb69928d
Коммит ac3efb4072
6 изменённых файлов: 100 добавлений и 105 удалений

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

@ -5,10 +5,10 @@ package vschema
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
proto "github.com/golang/protobuf/proto"
query "vitess.io/vitess/go/vt/proto/query"
topodata "vitess.io/vitess/go/vt/proto/topodata"
)
// Reference imports to suppress errors if they are not otherwise used.
@ -116,13 +116,13 @@ func (m *RoutingRule) GetToTables() []string {
// Keyspace is the vschema for a keyspace.
type Keyspace struct {
// If sharded is false, vindexes and tables are ignored.
Sharded bool `protobuf:"varint,1,opt,name=sharded,proto3" json:"sharded,omitempty"`
Vindexes map[string]*Vindex `protobuf:"bytes,2,rep,name=vindexes,proto3" json:"vindexes,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
Tables map[string]*Table `protobuf:"bytes,3,rep,name=tables,proto3" json:"tables,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
KeyspaceType topodata.KeyspaceType `protobuf:"varint,4,opt,name=keyspace_type,json=keyspaceType,proto3,enum=topodata.KeyspaceType" json:"keyspace_type,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
Sharded bool `protobuf:"varint,1,opt,name=sharded,proto3" json:"sharded,omitempty"`
Vindexes map[string]*Vindex `protobuf:"bytes,2,rep,name=vindexes,proto3" json:"vindexes,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
Tables map[string]*Table `protobuf:"bytes,3,rep,name=tables,proto3" json:"tables,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
RequireExplicitRouting bool `protobuf:"varint,4,opt,name=require_explicit_routing,json=requireExplicitRouting,proto3" json:"require_explicit_routing,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Keyspace) Reset() { *m = Keyspace{} }
@ -171,11 +171,11 @@ func (m *Keyspace) GetTables() map[string]*Table {
return nil
}
func (m *Keyspace) GetKeyspaceType() topodata.KeyspaceType {
func (m *Keyspace) GetRequireExplicitRouting() bool {
if m != nil {
return m.KeyspaceType
return m.RequireExplicitRouting
}
return topodata.KeyspaceType_NORMAL
return false
}
// Vindex is the vindex info for a Keyspace.
@ -561,48 +561,48 @@ func init() {
func init() { proto.RegisterFile("vschema.proto", fileDescriptor_3f6849254fea3e77) }
var fileDescriptor_3f6849254fea3e77 = []byte{
// 676 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0xdd, 0x4e, 0xdb, 0x4c,
0x10, 0x95, 0x13, 0x62, 0x92, 0x71, 0x12, 0xbe, 0x6f, 0x05, 0xd4, 0x35, 0x42, 0x44, 0x16, 0x6d,
0xd3, 0x5e, 0x38, 0x52, 0x50, 0xa5, 0x36, 0x88, 0xaa, 0x14, 0xf5, 0x02, 0x15, 0xa9, 0x95, 0x41,
0x5c, 0xf4, 0x26, 0x5a, 0x92, 0x2d, 0x58, 0x24, 0x5e, 0xb3, 0xbb, 0x76, 0x9b, 0x47, 0xe9, 0x6d,
0x5f, 0xab, 0xef, 0xd0, 0x67, 0xa8, 0xbc, 0x3f, 0x66, 0x03, 0xe9, 0xdd, 0x1e, 0xcf, 0x9c, 0x33,
0x67, 0xc7, 0x3b, 0x03, 0x9d, 0x82, 0x4f, 0x6e, 0xc8, 0x1c, 0x47, 0x19, 0xa3, 0x82, 0xa2, 0x75,
0x0d, 0x83, 0xae, 0xa0, 0x19, 0x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0x9a, 0x7b, 0xe5, 0x4a, 0x78, 0xf0, 0x37, 0x00, 0x00, 0xff, 0xff, 0x6b, 0x24, 0x60, 0x9d,
0xd6, 0x05, 0x00, 0x00,
// 673 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0xcf, 0x4e, 0xdb, 0x4e,
0x10, 0x96, 0x13, 0x62, 0x92, 0x31, 0x09, 0xbf, 0xdf, 0x0a, 0xa8, 0x1b, 0x84, 0x88, 0x2c, 0xda,
0xa6, 0x3d, 0x24, 0x52, 0x50, 0x25, 0x9a, 0x8a, 0xaa, 0x14, 0x71, 0x40, 0x45, 0x6a, 0x65, 0x10,
0x87, 0x5e, 0x2c, 0xe3, 0x6c, 0x61, 0x45, 0xe2, 0x35, 0xbb, 0x6b, 0x97, 0x3c, 0x4a, 0xaf, 0x7d,
0xad, 0x3e, 0x42, 0x5f, 0xa2, 0xf2, 0xfe, 0x31, 0x1b, 0x48, 0x6f, 0x3b, 0x3b, 0xf3, 0x7d, 0xf3,
0xed, 0xec, 0xcc, 0x40, 0xbb, 0xe0, 0xc9, 0x0d, 0x9e, 0xc5, 0x83, 0x8c, 0x51, 0x41, 0xd1, 0xaa,
0x36, 0xbb, 0xde, 0x5d, 0x8e, 0xd9, 0x5c, 0xdd, 0x06, 0x63, 0x58, 0x0b, 0x69, 0x2e, 0x48, 0x7a,
0x1d, 0xe6, 0x53, 0xcc, 0xd1, 0x1b, 0x68, 0xb0, 0xf2, 0xe0, 0x3b, 0xbd, 0x7a, 0xdf, 0x1b, 0x6d,
0x0c, 0x0c, 0x89, 0x15, 0x15, 0xaa, 0x90, 0xe0, 0x14, 0x3c, 0xeb, 0x16, 0xed, 0x00, 0x7c, 0x67,
0x74, 0x16, 0x89, 0xf8, 0x6a, 0x8a, 0x7d, 0xa7, 0xe7, 0xf4, 0x5b, 0x61, 0xab, 0xbc, 0xb9, 0x28,
0x2f, 0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0x4f, 0xda, 0x2e, 0x34, 0x39, 0xbe, 0xcb, 0x71, 0x9a, 0x18, 0xea, 0xca, 0x0e, 0x0e, 0xc1,
0x3d, 0x5e, 0x4c, 0xee, 0x58, 0xc9, 0x77, 0xf5, 0x57, 0x96, 0xa8, 0xce, 0xc8, 0x1b, 0xa8, 0x55,
0x74, 0x31, 0xcf, 0xb0, 0xfa, 0xd7, 0xe0, 0xb7, 0x03, 0x70, 0xce, 0x8a, 0xcb, 0x73, 0x59, 0x4c,
0xf4, 0x11, 0x5a, 0xb7, 0x7a, 0x38, 0xcd, 0x4a, 0x0a, 0xaa, 0x4a, 0x3f, 0xc4, 0x55, 0x13, 0xac,
0x9b, 0xf2, 0x01, 0x84, 0xc6, 0xd0, 0xd6, 0xd3, 0x1a, 0xa9, 0xc5, 0xa6, 0xa6, 0x63, 0x73, 0xd9,
0x62, 0xe3, 0xe1, 0x1a, 0xb3, 0xac, 0xee, 0x17, 0xe8, 0x2c, 0x12, 0x2f, 0x69, 0xe0, 0x57, 0x8b,
0x53, 0xf7, 0xff, 0x93, 0xa5, 0x62, 0xf5, 0xf4, 0xa7, 0x97, 0xdf, 0xf6, 0x0a, 0x22, 0x30, 0xe7,
0x03, 0x42, 0x87, 0xea, 0x34, 0xbc, 0xa6, 0xc3, 0x42, 0x0c, 0xe5, 0x36, 0x1e, 0x6a, 0xec, 0x95,
0x2b, 0xcd, 0xfd, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb8, 0xa7, 0x99, 0x19, 0xc3, 0x05, 0x00,
0x00,
}

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

@ -1638,16 +1638,17 @@ func commandCreateKeyspace(ctx context.Context, wr *wrangler.Wrangler, subFlags
wr.Logger().Infof("error from GetVSchema for base_keyspace: %v, %v", *baseKeyspace, err)
if topo.IsErrType(err, topo.NoNode) {
vs = &vschemapb.Keyspace{
Sharded: false,
Tables: make(map[string]*vschemapb.Table),
Vindexes: make(map[string]*vschemapb.Vindex),
KeyspaceType: ktype,
Sharded: false,
Tables: make(map[string]*vschemapb.Table),
Vindexes: make(map[string]*vschemapb.Vindex),
RequireExplicitRouting: true,
}
} else {
return err
}
} else {
vs.KeyspaceType = ktype
// SNAPSHOT keyspaces are excluded from global routing.
vs.RequireExplicitRouting = true
}
if err := wr.TopoServer().SaveVSchema(ctx, keyspace, vs); err != nil {
wr.Logger().Infof("error from SaveVSchema %v:%v", vs, err)

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

@ -292,7 +292,7 @@ func TestAPI(t *testing.T) {
}`},
{"POST", "vtctl/", `["GetVSchema","ks3"]`, `{
"Error": "",
"Output": "{\n \"sharded\": true,\n \"vindexes\": {\n \"name1\": {\n \"type\": \"hash\"\n }\n },\n \"tables\": {\n \"table1\": {\n \"columnVindexes\": [\n {\n \"column\": \"column1\",\n \"name\": \"name1\"\n }\n ]\n }\n },\n \"keyspaceType\": \"SNAPSHOT\"\n}\n\n"
"Output": "{\n \"sharded\": true,\n \"vindexes\": {\n \"name1\": {\n \"type\": \"hash\"\n }\n },\n \"tables\": {\n \"table1\": {\n \"columnVindexes\": [\n {\n \"column\": \"column1\",\n \"name\": \"name1\"\n }\n ]\n }\n },\n \"requireExplicitRouting\": true\n}\n\n"
}`},
{"POST", "vtctl/", `["GetKeyspace","does_not_exist"]`, `{
"Error": "node doesn't exist: keyspaces/does_not_exist/Keyspace",

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

@ -225,12 +225,8 @@ func buildTables(ks *vschemapb.Keyspace, vschema *VSchema, ksvschema *KeyspaceSc
return err
}
// SNAPSHOT keyspaces are excluded from global routing.
// We only have 2 keyspace types as of now, NORMAL and SNAPSHOT.
// We check for NORMAL here so that if a new keyspace type is
// introduced we will need to explicitly decide to include it
// in the global routing rather than have it happen by default.
if ks.KeyspaceType == topodatapb.KeyspaceType_NORMAL {
// If the keyspace requires explicit routing, don't include it in global routing
if !ks.RequireExplicitRouting {
if _, ok := vschema.uniqueVindexes[vname]; ok {
vschema.uniqueVindexes[vname] = nil
} else {
@ -334,8 +330,8 @@ func buildTables(ks *vschemapb.Keyspace, vschema *VSchema, ksvschema *KeyspaceSc
t.Ordered = colVindexSorted(t.ColumnVindexes)
// Add the table to the map entries.
// SNAPSHOT keyspaces are excluded from global routing.
if ks.KeyspaceType == topodatapb.KeyspaceType_NORMAL {
// If the keyspace requires explicit routing, don't include it in global routing
if !ks.RequireExplicitRouting {
if _, ok := vschema.uniqueTables[tname]; ok {
vschema.uniqueTables[tname] = nil
} else {

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

@ -21,7 +21,6 @@ option go_package = "vitess.io/vitess/go/vt/proto/vschema";
package vschema;
import "topodata.proto";
import "query.proto";
// RoutingRules specify the high level routing rules for the VSchema.
@ -44,7 +43,8 @@ message Keyspace {
bool sharded = 1;
map<string, Vindex> vindexes = 2;
map<string, Table> tables = 3;
topodata.KeyspaceType keyspace_type = 4;
// If require_explicit_routing is true, vindexes and tables are not added to global routing
bool require_explicit_routing = 4;
}
// Vindex is the vindex info for a Keyspace.

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

@ -12,7 +12,6 @@ from google.protobuf import symbol_database as _symbol_database
_sym_db = _symbol_database.Default()
import topodata_pb2 as topodata__pb2
import query_pb2 as query__pb2
@ -21,9 +20,9 @@ DESCRIPTOR = _descriptor.FileDescriptor(
package='vschema',
syntax='proto3',
serialized_options=_b('Z$vitess.io/vitess/go/vt/proto/vschema'),
serialized_pb=_b('\n\rvschema.proto\x12\x07vschema\x1a\x0etopodata.proto\x1a\x0bquery.proto\"3\n\x0cRoutingRules\x12#\n\x05rules\x18\x01 \x03(\x0b\x32\x14.vschema.RoutingRule\"4\n\x0bRoutingRule\x12\x12\n\nfrom_table\x18\x01 \x01(\t\x12\x11\n\tto_tables\x18\x02 \x03(\t\"\xad\x02\n\x08Keyspace\x12\x0f\n\x07sharded\x18\x01 \x01(\x08\x12\x31\n\x08vindexes\x18\x02 \x03(\x0b\x32\x1f.vschema.Keyspace.VindexesEntry\x12-\n\x06tables\x18\x03 \x03(\x0b\x32\x1d.vschema.Keyspace.TablesEntry\x12-\n\rkeyspace_type\x18\x04 \x01(\x0e\x32\x16.topodata.KeyspaceType\x1a@\n\rVindexesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1e\n\x05value\x18\x02 \x01(\x0b\x32\x0f.vschema.Vindex:\x02\x38\x01\x1a=\n\x0bTablesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1d\n\x05value\x18\x02 \x01(\x0b\x32\x0e.vschema.Table:\x02\x38\x01\"\x81\x01\n\x06Vindex\x12\x0c\n\x04type\x18\x01 \x01(\t\x12+\n\x06params\x18\x02 \x03(\x0b\x32\x1b.vschema.Vindex.ParamsEntry\x12\r\n\x05owner\x18\x03 \x01(\t\x1a-\n\x0bParamsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\xca\x01\n\x05Table\x12\x0c\n\x04type\x18\x01 \x01(\t\x12.\n\x0f\x63olumn_vindexes\x18\x02 \x03(\x0b\x32\x15.vschema.ColumnVindex\x12.\n\x0e\x61uto_increment\x18\x03 \x01(\x0b\x32\x16.vschema.AutoIncrement\x12 \n\x07\x63olumns\x18\x04 \x03(\x0b\x32\x0f.vschema.Column\x12\x0e\n\x06pinned\x18\x05 \x01(\t\x12!\n\x19\x63olumn_list_authoritative\x18\x06 \x01(\x08\"=\n\x0c\x43olumnVindex\x12\x0e\n\x06\x63olumn\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x0f\n\x07\x63olumns\x18\x03 \x03(\t\"1\n\rAutoIncrement\x12\x0e\n\x06\x63olumn\x18\x01 \x01(\t\x12\x10\n\x08sequence\x18\x02 \x01(\t\"1\n\x06\x43olumn\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x19\n\x04type\x18\x02 \x01(\x0e\x32\x0b.query.Type\"\xb6\x01\n\nSrvVSchema\x12\x35\n\tkeyspaces\x18\x01 \x03(\x0b\x32\".vschema.SrvVSchema.KeyspacesEntry\x12,\n\rrouting_rules\x18\x02 \x01(\x0b\x32\x15.vschema.RoutingRules\x1a\x43\n\x0eKeyspacesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12 \n\x05value\x18\x02 \x01(\x0b\x32\x11.vschema.Keyspace:\x02\x38\x01\x42&Z$vitess.io/vitess/go/vt/proto/vschemab\x06proto3')
serialized_pb=_b('\n\rvschema.proto\x12\x07vschema\x1a\x0bquery.proto\"3\n\x0cRoutingRules\x12#\n\x05rules\x18\x01 \x03(\x0b\x32\x14.vschema.RoutingRule\"4\n\x0bRoutingRule\x12\x12\n\nfrom_table\x18\x01 \x01(\t\x12\x11\n\tto_tables\x18\x02 \x03(\t\"\xa0\x02\n\x08Keyspace\x12\x0f\n\x07sharded\x18\x01 \x01(\x08\x12\x31\n\x08vindexes\x18\x02 \x03(\x0b\x32\x1f.vschema.Keyspace.VindexesEntry\x12-\n\x06tables\x18\x03 \x03(\x0b\x32\x1d.vschema.Keyspace.TablesEntry\x12 \n\x18require_explicit_routing\x18\x04 \x01(\x08\x1a@\n\rVindexesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1e\n\x05value\x18\x02 \x01(\x0b\x32\x0f.vschema.Vindex:\x02\x38\x01\x1a=\n\x0bTablesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1d\n\x05value\x18\x02 \x01(\x0b\x32\x0e.vschema.Table:\x02\x38\x01\"\x81\x01\n\x06Vindex\x12\x0c\n\x04type\x18\x01 \x01(\t\x12+\n\x06params\x18\x02 \x03(\x0b\x32\x1b.vschema.Vindex.ParamsEntry\x12\r\n\x05owner\x18\x03 \x01(\t\x1a-\n\x0bParamsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\xca\x01\n\x05Table\x12\x0c\n\x04type\x18\x01 \x01(\t\x12.\n\x0f\x63olumn_vindexes\x18\x02 \x03(\x0b\x32\x15.vschema.ColumnVindex\x12.\n\x0e\x61uto_increment\x18\x03 \x01(\x0b\x32\x16.vschema.AutoIncrement\x12 \n\x07\x63olumns\x18\x04 \x03(\x0b\x32\x0f.vschema.Column\x12\x0e\n\x06pinned\x18\x05 \x01(\t\x12!\n\x19\x63olumn_list_authoritative\x18\x06 \x01(\x08\"=\n\x0c\x43olumnVindex\x12\x0e\n\x06\x63olumn\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x0f\n\x07\x63olumns\x18\x03 \x03(\t\"1\n\rAutoIncrement\x12\x0e\n\x06\x63olumn\x18\x01 \x01(\t\x12\x10\n\x08sequence\x18\x02 \x01(\t\"1\n\x06\x43olumn\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x19\n\x04type\x18\x02 \x01(\x0e\x32\x0b.query.Type\"\xb6\x01\n\nSrvVSchema\x12\x35\n\tkeyspaces\x18\x01 \x03(\x0b\x32\".vschema.SrvVSchema.KeyspacesEntry\x12,\n\rrouting_rules\x18\x02 \x01(\x0b\x32\x15.vschema.RoutingRules\x1a\x43\n\x0eKeyspacesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12 \n\x05value\x18\x02 \x01(\x0b\x32\x11.vschema.Keyspace:\x02\x38\x01\x42&Z$vitess.io/vitess/go/vt/proto/vschemab\x06proto3')
,
dependencies=[topodata__pb2.DESCRIPTOR,query__pb2.DESCRIPTOR,])
dependencies=[query__pb2.DESCRIPTOR,])
@ -54,8 +53,8 @@ _ROUTINGRULES = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=55,
serialized_end=106,
serialized_start=39,
serialized_end=90,
)
@ -92,8 +91,8 @@ _ROUTINGRULE = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=108,
serialized_end=160,
serialized_start=92,
serialized_end=144,
)
@ -130,8 +129,8 @@ _KEYSPACE_VINDEXESENTRY = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=337,
serialized_end=401,
serialized_start=308,
serialized_end=372,
)
_KEYSPACE_TABLESENTRY = _descriptor.Descriptor(
@ -167,8 +166,8 @@ _KEYSPACE_TABLESENTRY = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=403,
serialized_end=464,
serialized_start=374,
serialized_end=435,
)
_KEYSPACE = _descriptor.Descriptor(
@ -200,9 +199,9 @@ _KEYSPACE = _descriptor.Descriptor(
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='keyspace_type', full_name='vschema.Keyspace.keyspace_type', index=3,
number=4, type=14, cpp_type=8, label=1,
has_default_value=False, default_value=0,
name='require_explicit_routing', full_name='vschema.Keyspace.require_explicit_routing', index=3,
number=4, type=8, cpp_type=7, label=1,
has_default_value=False, default_value=False,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
@ -218,8 +217,8 @@ _KEYSPACE = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=163,
serialized_end=464,
serialized_start=147,
serialized_end=435,
)
@ -256,8 +255,8 @@ _VINDEX_PARAMSENTRY = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=551,
serialized_end=596,
serialized_start=522,
serialized_end=567,
)
_VINDEX = _descriptor.Descriptor(
@ -300,8 +299,8 @@ _VINDEX = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=467,
serialized_end=596,
serialized_start=438,
serialized_end=567,
)
@ -366,8 +365,8 @@ _TABLE = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=599,
serialized_end=801,
serialized_start=570,
serialized_end=772,
)
@ -411,8 +410,8 @@ _COLUMNVINDEX = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=803,
serialized_end=864,
serialized_start=774,
serialized_end=835,
)
@ -449,8 +448,8 @@ _AUTOINCREMENT = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=866,
serialized_end=915,
serialized_start=837,
serialized_end=886,
)
@ -487,8 +486,8 @@ _COLUMN = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=917,
serialized_end=966,
serialized_start=888,
serialized_end=937,
)
@ -525,8 +524,8 @@ _SRVVSCHEMA_KEYSPACESENTRY = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=1084,
serialized_end=1151,
serialized_start=1055,
serialized_end=1122,
)
_SRVVSCHEMA = _descriptor.Descriptor(
@ -562,8 +561,8 @@ _SRVVSCHEMA = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=969,
serialized_end=1151,
serialized_start=940,
serialized_end=1122,
)
_ROUTINGRULES.fields_by_name['rules'].message_type = _ROUTINGRULE
@ -573,7 +572,6 @@ _KEYSPACE_TABLESENTRY.fields_by_name['value'].message_type = _TABLE
_KEYSPACE_TABLESENTRY.containing_type = _KEYSPACE
_KEYSPACE.fields_by_name['vindexes'].message_type = _KEYSPACE_VINDEXESENTRY
_KEYSPACE.fields_by_name['tables'].message_type = _KEYSPACE_TABLESENTRY
_KEYSPACE.fields_by_name['keyspace_type'].enum_type = topodata__pb2._KEYSPACETYPE
_VINDEX_PARAMSENTRY.containing_type = _VINDEX
_VINDEX.fields_by_name['params'].message_type = _VINDEX_PARAMSENTRY
_TABLE.fields_by_name['column_vindexes'].message_type = _COLUMNVINDEX